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!