Unresolved external symbol with Qt6
-
Hi, I am trying to build a Qt6 project on windows 10. I am using conan for dependency management (so thats what is pulling in Qt) and cmake with a VS generator. I am getting the following linker error though:
Qt6Guid.lib(qrhid3d11.cpp.obj) : error LNK2019: unresolved external symbol DCompositionCreateDevice referenced in function "public: bool __cdecl QRhiD3D11::ensureDirectCompositionDevice(void)" (?ensureDirectCompositionDevice@QRhiD3D11@@QEAA_NXZ)
So it looks like its having trouble linking to D3D11. From my understanding, it shouldn't need me to explicitly link to that as the VS generator automatically knows where the Windows SDK is and QT should have that linked in its distro anyways. Any Idea what to do here?
-
@ChrisW67 Im just using conan to get the dependency package, it doesn't do any building. Then it sets things up in a nice Cmake namespace. Only code regarding qt in the cmake file is this single line adding it to the link libraries:
add_library(QtGUIImpl STATIC ${SOURCE} ${HEADERS} ) target_link_libraries(QtGUIImpl CONAN_PKG::qt)
Then just run the cmake --build .
I link all sorts of other conan packages the same way and never faced any issues. For example this link gtest just fine and I do the same with spdlog:
target_link_libraries(SpdlogImplTest CONAN_PKG::gtest SpdlogImpl Utilities)
I wonder if the conan package in their artifactory is actually broken.
-
@ChrisW67 Looks like the conan package is broken. I had to explicitly link with a dcomp.lib windows library, but that fixed it. Did a search in the windows docs for the missing symbol and just copy and pasted its static lib. Whether or not this runs is a different story:
target_link_libraries(QtGUIImpl CONAN_PKG::qt Dcomp.lib)