Configure & Build Qt 5.15.1 with MSVC 19.12 using external 3rd party libraries
-
I'm trying to build the Open Source edition of Qt v5.15.1 from source, using qt-everywhere-src-5.15.1.zip.
The toolchain is
x64-windows-msvc1912-v141-dynamic-md
(OS: Windows 7).This means in summary:
- Build Qt LGPLv3 modules only.
- Build Qt shared libraries only.
- Use the compiler MSVC 19.12 with the platform toolset v141.
- Use the shared Run-Time Library.
Some of the 3rd party libraries (e.g. libtiff, zlib) Qt uses are already dependencies of existing components in my source code. In order to avoid problems due to ABI/API incompatibilities between the already build external 3rd party libraries and the bundled Qt 3rd party libraries I would like to configure Qt to use the already build ones.
Here are my problems:
-
I'm unable to build both the
Release
and theDebug
build config when using external 3rd party libraries. It seems that the Qt build tries to use theRelease
library file for theDebug
config as well. This results in_ITERATOR_DEBUG_LEVEL
andRuntimeLibrary
mismatch errors raised by MSVC. Each 3rd party library is build and "installed" using its official CMake file. The install tree for an external 3rd party library looks as follows:double-conversion-3.1.5 +---x64-windows-msvc1912-v141-dynamic-md | +---bin | | double-conversion.dll | | double-conversiond.dll | +---include | | [...] | \---lib | | double-conversion.lib | | double-conversiond.lib | [...] \---x64-windows-msvc1912-v141-static-md +---include | | [...] \---lib | double-conversion.lib | double-conversiond.lib [...]
-
I'm able to build Qt with the
Release
build config using only shared external 3rd party libraries. I would like to avoid this in order to minimize the total number of runtime dependencies. Trying to configure/build Qt using only static external 3rd party libraries fails (libjpeg, libpng, libtiff). This issue seems to be related to the following:- Existing compile/link dependencies between the prebuilt 3rd party libraries libraries (e.g. libtiff uses libjpeg, libpng uses zlib, etc.).
- The Qt build wants to use a diffent install tree filesystem layout for 3rd party libraries (e.g. libpng uses the filename
libpng16_static.lib
).
The following
configure
call is currently used:configure.bat^ -recheck-all^ -prefix "%install_prefix%"^ -opensource^ -confirm-license^ -debug-and-release^ -shared^ -platform win32-msvc^ -c++std 11^ -make-tool jom^ -mp^ -silent^ -skip qtcharts^ -skip qtdatavis3d^ -skip qtlottie^ -skip qtnetworkauth^ -skip qtvirtualkeyboard^ -skip qtquick3d^ -skip webglplugin^ -skip webengine^ -nomake examples^ -nomake tests^ -gui^ -widgets^ -accessibility^ -no-glib^ -no-icu^ -ssl^ -schannel^ -opengl dynamic^ -no-assimp^ -system-doubleconversion^ -system-freetype^ -system-harfbuzz^ -system-libjpeg^ -system-libpng^ -system-pcre^ -system-sqlite^ -system-tiff^ -no-webp^ -system-zlib^ -I "%assimp_path%\include"^ -L "%assimp_path%\lib"^ -I "%doubleconversion_path%\include"^ -L "%doubleconversion_path%\lib"^ -I "%freetype_path%\include"^ -L "%freetype_path%\lib"^ -I "%harfbuzz_path%\include"^ -L "%harfbuzz_path%\lib"^ -I "%libjpeg_path%\include"^ -L "%libjpeg_path%\lib"^ -I "%libpng_path%\include"^ -L "%libpng_path%\lib"^ -I "%pcre2_path%\include"^ -L "%pcre2_path%\lib"^ -I "%sqlite_path%\include"^ -L "%sqlite_path%\lib"^ -I "%libtiff_path%\include"^ -L "%libtiff_path%\lib"^ -I "%libwebp_path%\include"^ -L "%libwebp_path%\lib"^ -I "%zlib_path%\include"^ -L "%zlib_path%\lib"
My questions are:
- Is there any way to specify the filename of each external 3rd party library for each build config, e.g. something like
-D LIBPNG_LIBRARY_DEBUG=libpng16_staticd.lib
and-D LIBPNG_LIBRARY_RELEASE=libpng16_static.lib
? - Is it required to use another install tree filesystem layout for the external 3rd party libraries and use two shadow builds (one using
-debug
and one usingrelease
)? - Is it required to build the external 3rd party libraries with a very specific set of configure options? For example, breaks the dependency from libtiff to libjpeg (or any other dependency) the Qt build?
- Is all this unnecessary and I should use the libraries shipped with Qt because ABI/API concerns are not a problem in this case?
In general, I need some advice how-to deal with this issues.
Update: I've been able to build Qt with "minimal" bundled dependencies (
-qt-doubleconversion
and-qt-pcre
, all other set with the-no-
prefix). In this case the two 3rd party libraries seem to be linked static. -
Hi,
From memory, on Windows, the usual way to separate debug and release builds is to use two different folders and use the same library name for both builds. Not the most practical indeed.
If you want to custom these, you will likely have to tweak the .json files of the feature system of Qt. I am not sure it's worth the effort.
-
Hi,
From memory, on Windows, the usual way to separate debug and release builds is to use two different folders and use the same library name for both builds. Not the most practical indeed.
If you want to custom these, you will likely have to tweak the .json files of the feature system of Qt. I am not sure it's worth the effort.
@SGaist Thanks for the answer. It seems one have to come up with a custom implemented superbuild (preferably in CMake) that does the build/install of the 3rd party libraries, renaming of library files (to be picked up by Qt, these are temporary files that can be deleted later), shadow building twice (one for debug, one for release, both with different paths pointing to the correct library files). Then a shared version of Qt (but with statically linked 3rd party libraries) should be possible.
Wow...
Certainly doable, but I think I will go with minimal deps first. VTK is on my list too, which bundles a lot more libraries... I think building Qt is easy in comparison to VTK. This takes so many hours. The C++ ecosystem is still a disgrace, imo.
-
@FlorianWolters I'm facing the same issue, were you able to figure out a solution?