Closed matheusgomes28 closed 12 months ago
The error message says that you need to build qt as a static library if the runtime is static. Can you please try with option qt/*:shared=False
?
To update: @ericLemanissier's suggestion indeed worked. I accidentally had qt/*:shared=True
in my recipe, and that would cause the build to fail.
It would be nice if the recipe detected this mismatch in configuration (MSVC_RUNTIME_LIBRARY=Mt
and qt/*:shared=True
and failed to configure).
Forgot to update: After building (which was fine), I have not yet managed to actually compile any targets linked to the Qt6::*
libraries. The following linker error is what I get
[build] Creating library C:/Users/mathe/development/discotec/build/vs2022-deb/src/audio_visualizer/Debug/visualizer.lib and object C:/Users/mathe/development/discotec/build/vs2022-deb/src/audio_visualizer/Debug/visualizer.exp
[build] Qt6Guid.lib(qrhid3d11.cpp.obj) : error LNK2019: unresolved external symbol DCompositionCreateDevice referenced in function "public: bool __cdecl QRhiD3D11::ensureDirectCompositionDevice(void)" (?ensureDirectCompositionDevice@QRhiD3D11@@QEAA_NXZ) [C:\Users\mathe\development\discotec\build\vs2022-deb\src\audio_visualizer\visualizer.vcxproj]
[build] C:\Users\mathe\development\discotec\build\vs2022-deb\src\audio_visualizer\Debug\visualizer.exe : fatal error LNK1120: 1 unresolved externals [C:\Users\mathe\development\discotec\build\vs2022-deb\src\audio_visualizer\visualizer.vcxproj]
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" --build C:/Users/mathe/development/discotec/build/vs2022-deb --config Debug exited with code: 1
[driver] Build completed: 00:00:17.239
[build] Build finished with exit code 1
For those running into this error, refer to this Qt6 forum post for a possible fix. It seems like the library isn't linking to Dcomp.lib
Yet another edit: You will need to include something like this if you're compiling statically for Windows, as the recipe somehow doesn't cascade these dependencies on Windows builds:
if (WIN32)
target_link_libraries(my_qt_application
PRIVATE
Qt6::QWindowsIntegrationPlugin
Dcomp.lib
shcore.lib
d3d9.lib
SetupApi.lib)
endif()
As well as something like this in your linkeable targets in Windows:
#ifdef WINDOWS
#include <QtPlugin>
Q_IMPORT_PLUGIN (QWindowsIntegrationPlugin)
#endif // WINDOWS
I have not yet been able to compile Qt statically with certain extra modules (such as the Multimedia module by enabling self.options["qt/*"].qtmultimedia = True
in my conanfile.py
). It seems to have conflicting settings in the recipe:
======== Computing dependency graph ========
ERROR: qt/6.5.2: Error in configure() method, line 221
_enablemodule(module)
while calling '_enablemodule', line 217
_enablemodule(req)
while calling '_enablemodule', line 215
setattr(self.options, mod, True)
ConanException: Incorrect attempt to modify option 'qtshadertools' from 'False' to 'True'
the dcomp
problem should be gone with qt 6.5.3, cf https://github.com/qt/qtbase/commit/63402812ced3d715eb298900f8efa7aef85dd271
Could you please try and confirm @matheusgomes28 ?
Description
When attempting to build my Qt6 application on my Windows machine, it fails on the Qt6 checks for the
static
runtime build. See the logs for the exact details.Note that, building with the
MSVC_RUNTIME_LIBRARY
set toMultiThreaded{Debug}DLL
(i.e.compiler.runtime=dynamic
) then it builds just fine.As far as I can tell, Qt6 does provide support for building with a static runtime as outlined in their docs, so this is something that should also be supported in the conan recipe.
Package and Environment Details
Conan profile
[settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=17 compiler.runtime=dynamic compiler.version=193 os=Windows
Steps to reproduce
conan install . -sbuild_type=Debug -of=conan --build=missing
Logs
Click to expand logs