Results 1 to 3 of 3

Thread: Cannot link against jpeglib and turbojpeg in QtCreator project

  1. #1
    Join Date
    Jul 2015
    Posts
    22
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Cannot link against jpeglib and turbojpeg in QtCreator project

    Dear all,

    I have the following minimal working example in QtCreator in which I am trying to use Qt together with libjpeg and libjpeg-turbo:

    Appplication.pro:
    Qt Code:
    1. QT += core gui
    2.  
    3. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    4.  
    5. TARGET = Application
    6. TEMPLATE = app
    7.  
    8.  
    9. SOURCES += main.cpp\
    To copy to clipboard, switch view to plain text mode 

    main.cpp:
    Qt Code:
    1. #include <QFile>
    2.  
    3. #include <turbojpeg.h>
    4. #include <jpeglib.h>
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. // Step 1: disk to qbytearray
    9. QFile file("example.jpg");
    10. file.open(QIODevice::ReadOnly);
    11. QByteArray blob = file.readAll();
    12. file.close();
    13.  
    14.  
    15. // Step 2: Trying to use what's declared in jpeglib.h in order to decompress the file which was just read
    16. struct jpeg_decompress_struct cinfo;
    17. struct jpeg_error_mgr jerr;
    18. cinfo.err = jpeg_std_error(&jerr);
    19. jpeg_create_decompress(&cinfo);
    20. //...... if the above lines worked, some more code would be added here ....
    21.  
    22.  
    23. // Step 3: Trying to use what's declared in turbojpeg.h
    24. long unsigned int _jpegSize;
    25. unsigned char* _compressedImage;
    26.  
    27. int jpegSubsamp, width, height;
    28. unsigned char buffer[width*height*3]; //!< will contain the decompressed image
    29.  
    30. tjhandle _jpegDecompressor = tjInitDecompress();
    31. //...... if the above lines worked, some more code would be added here ....
    32.  
    33. return 0;
    34. }
    To copy to clipboard, switch view to plain text mode 


    Files turbojpeg.h and jpeglib.h are both included in /usr/include on my computer (running Debian Jessie). If I dpkg -l *jpeg*, then I get the following. It's in german, but I guess everybody will be able to figure out, what it means.

    Qt Code:
    1. Gewünscht=Unbekannt/Installieren/R=Entfernen/P=Vollständig Löschen/Halten
    2. | Status=Nicht/Installiert/Config/U=Entpackt/halb konFiguriert/
    3. Halb installiert/Trigger erWartet/Trigger anhängig
    4. |/ Fehler?=(kein)/R=Neuinstallation notwendig (Status, Fehler: GROSS=schlecht)
    5. ||/ Name Version Architektur Beschreibung
    6. +++-==============================-====================-====================-=================================================================
    7. un libjpeg-dev <keine> <keine> (keine Beschreibung vorhanden)
    8. un libjpeg-progs <keine> <keine> (keine Beschreibung vorhanden)
    9. ii libjpeg-turbo-progs 1:1.3.1-12 amd64 Programs for manipulating JPEG files
    10. un libjpeg-turbo8 <keine> <keine> (keine Beschreibung vorhanden)
    11. un libjpeg62 <keine> <keine> (keine Beschreibung vorhanden)
    12. un libjpeg62-dbg <keine> <keine> (keine Beschreibung vorhanden)
    13. un libjpeg62-dev <keine> <keine> (keine Beschreibung vorhanden)
    14. ii libjpeg62-turbo:amd64 1:1.3.1-12 amd64 libjpeg-turbo JPEG runtime library
    15. ii libjpeg62-turbo-dbg:amd64 1:1.3.1-12 amd64 Debugging symbols for the libjpeg-turbo JPEG library
    16. ii libjpeg62-turbo-dev:amd64 1:1.3.1-12 amd64 Development files for the libjpeg-turbo JPEG library
    17. un libjpeg7-dev <keine> <keine> (keine Beschreibung vorhanden)
    18. un libjpeg8-dev <keine> <keine> (keine Beschreibung vorhanden)
    19. un libjpeg9-dev <keine> <keine> (keine Beschreibung vorhanden)
    20. ii libopenjpeg5:amd64 1:1.5.2-3 amd64 JPEG 2000 image compression/decompression library - runtime
    21. un libturbojpeg <keine> <keine> (keine Beschreibung vorhanden)
    22. ii libturbojpeg1:amd64 1:1.3.1-12 amd64 TurboJPEG runtime library - SIMD optimized
    To copy to clipboard, switch view to plain text mode 

    In addition, I also compiled libjpeg-turbo-1.4.1 from source as is described here: http://igor-zivkovic.from.hr/BLFS/general/libjpeg.html
    I don't know why I did that... Maybe I was just desperate and did not know, what else to do to get it working ...

    I am using compiler GCC for 64 bit, which QtCreator auto-detected in /usr/bin.
    Compiling the above project gives the following error results:

    Qt Code:
    1. /home/ron/QtCreator/MWElibjpegForQtForum/Application/main.cpp:18: error: undefined reference to `jpeg_std_error'
    2. /home/ron/QtCreator/MWElibjpegForQtForum/Application/main.cpp:19: error: undefined reference to `jpeg_CreateDecompress'
    3. /home/ron/QtCreator/MWElibjpegForQtForum/Application/main.cpp:30: error: undefined reference to `tjInitDecompress'
    To copy to clipboard, switch view to plain text mode 

    I can see in turbojpeg.h that the header seems to be compiled for Windows, as it starts with:
    Qt Code:
    1. #if defined(_WIN32) && defined(DLLDEFINE)
    2. #define DLLEXPORT __declspec(dllexport)
    3. #else
    4. #define DLLEXPORT
    5. #endif
    6. #define DLLCALL
    To copy to clipboard, switch view to plain text mode 

    However, this is not consistent with the typical approach which I have seen a couple of times in tutorials, etc. such as here: https://www.ibm.com/developerworks :/aix/library/au-porting/
    Qt Code:
    1. #ifdef DLLDEFINE
    2. #define DLLEXPORT __declspec(dllexport)
    3. #else
    4. #define DLLEXPORT __declspec(dllimport)
    5. #endif
    To copy to clipboard, switch view to plain text mode 

    So, I am kind of confused how the two libs were supposed to be used...

    Does anybody have an idea how to get this thing working? Your help is very much appreciated. Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Cannot link against jpeglib and turbojpeg in QtCreator project

    Quote Originally Posted by donelron View Post
    I am using compiler GCC for 64 bit, which QtCreator auto-detected in /usr/bin.
    Compiling the above project gives the following error results:

    Qt Code:
    1. /home/ron/QtCreator/MWElibjpegForQtForum/Application/main.cpp:18: error: undefined reference to `jpeg_std_error'
    2. /home/ron/QtCreator/MWElibjpegForQtForum/Application/main.cpp:19: error: undefined reference to `jpeg_CreateDecompress'
    3. /home/ron/QtCreator/MWElibjpegForQtForum/Application/main.cpp:30: error: undefined reference to `tjInitDecompress'
    To copy to clipboard, switch view to plain text mode 
    The linker complains that there are certain symbols used by your program that it can't find anywhere.
    You are using functions that your program does not provide itself but you are also not linking to any libraries that would provide these.

    You need to specify their path and name in the .pro file, using the LIBS variable.

    Cheers,
    _

  3. #3
    Join Date
    Jul 2015
    Posts
    22
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Cannot link against jpeglib and turbojpeg in QtCreator project

    Sorry for not answering for some time. Unfortunately I just could not make some free time to deal with this thing....
    I opened my .pro file and used rightclick->Add library-> internal library to add. I think, that especially for someone who is rather new to QtCrator this is easier...
    Thanks for your help!!!

Similar Threads

  1. Replies: 2
    Last Post: 5th October 2012, 11:58
  2. Link a .dll library to a Qt project
    By n3500 in forum Qt Programming
    Replies: 2
    Last Post: 27th July 2012, 11:31
  3. How to link win32 dll to project?
    By libed in forum Qt Programming
    Replies: 7
    Last Post: 22nd July 2011, 16:22
  4. QTCreator GUI How to link button with textarea
    By chs in forum Qt Programming
    Replies: 8
    Last Post: 23rd May 2011, 07:30
  5. QtCreator change in lib should force a link
    By Braunstein in forum Qt Tools
    Replies: 1
    Last Post: 19th March 2010, 20:27

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.