Include libjpeg-turbo header file included in Qt
-
@Christian-Ehrlicher Wouldn't just copying the jpeg lib result in build errors? Because if I build Qt by specifying path to release version of libjpeg, but then try to build my program in debug mode - msvc will complain about debug vs release crt runtime conflict. Reason being my program + qt libraries will be using debug crt runtime, but libjpeg will be referencing the release one.
Found this: https://forum.qt.io/topic/75056/configuring-qt-what-replaces-debug-and-release/
This guy had the same issue as mine. He built two versions of Qt, one debug and other release in separate folders, But installed them into a single folder. That way he got both builds using correct release and debug 3rd party libraries as well. What about this approach?
-
On Windows the debug library normally has a 'd' suffix to distinguish between debug and release libs so you don't override them by copying. If you don't like to coy it, use the qmake function.
-
@Christian-Ehrlicher Can you explain the copy approach i.e. just copy the libjpeg I built (both debug and release) into existing Qt lib folder? or should I build Qt using those versions? If later, then how do I ensure that debug and release builds of Qt reference the appropriate debug/release version of libjpeg?
I'm using MSVC for building, how do I use qmake?
-
@Taytoo said in Include libjpeg-turbo header file included in Qt:
I have debug and release versions of libjpeg-turbo in separate folders. How do I specify correct folder for each Qt build i.e. debug and release?
You mean you want to do a combined -debug-and-release build? I don't think that's easily possible, because Qt will always assume the library is called 'libjpeg.lib'. The approach @Christian-Ehrlicher refers to works though for the part where you link against libjpeg yourself, in your app.
Anyhow, do you really need a separate debug build of libjpeg? AFAIK libjpeg is C API only, in which case there's no problem with linking a release build of libjpeg also with a debug build of Qt libraries.
-
I figured out the proper way to do this.
In Qt configure command use flag -system-libjpeg, then later specify options:
LIBJPEG_LIBS="<path to release static library file>" [Note: This is full path to jpeg.lib including filename]
-I <path to libjpeg include dir> [Note: This is path to the directory containing include file]@kkoehne You're right, I was able to use release version of libjpeg static lib in my debug program without any issue.
-
@Houda_ATTIG said in Include libjpeg-turbo header file included in Qt:
I am a beginner with Qt can you please tell me how to build libjpeg myself locally?
Building libjepeg has nothing to do with Qt.
Download libjpeg source code (https://sourceforge.net/projects/libjpeg/) and read install.doc file included in the source code archive. -
First of all thanks for your answer.
well I am using windows 10 with Qt creator, which files am I supposed to choose?Makefile jconfig file System and/or compiler
makefile.manx jconfig.manx Amiga, Manx Aztec C
makefile.sas jconfig.sas Amiga, SAS C
makeproj.mac jconfig.mac Apple Macintosh, Metrowerks CodeWarrior
makjpeg.st jconfig.st Atari ST/STE/TT, Pure C or Turbo C
makefile.bcc jconfig.bcc MS-DOS or OS/2, Borland C
makefile.dj jconfig.dj MS-DOS, DJGPP (Delorie's port of GNU C)
makefile.mc6 jconfig.mc6 MS-DOS, Microsoft C (16-bit only)
makefile.wat jconfig.wat MS-DOS, OS/2, or Windows NT, Watcom C
makefile.vc jconfig.vc Windows, MS Visual C++
makefile.vs jconfig.vc Windows, MS Visual C++ 6 Developer Studio
make.vc6
makefile.vs jconfig.vc Windows, Visual Studio 2019 (v16)
make*.v16
makefile.b32 jconfig.vc Windows, Borland C++ 32-bit (bcc32)
makefile.mms jconfig.vms Digital VMS, with MMS software
makefile.vms jconfig.vms Digital VMS, without MMS software -
@Houda_ATTIG Probably
makefile.vc jconfig.vc Windows NT/95, MS Visual C++
But you will need MSVC++ compiler.
-
Use this: https://github.com/microsoft/vcpkg
vcpkg allows your to build 100s of open source libraries with a single command e.g. ".\vcpkg install libjpeg-turbo". It also copies header and lib files to a specific folder that you only need to include once in your project.
Make the effort to get familiar with vcpkg, it will save you a lot of time trying to build/use open source libraries.