link errors with cmake and 6.2.0 static build on windows
-
I am using qtcreator. I have made a static build of 6.2.0 on windows.
If I use the downloadable DLL release, I can build my project perfectly (both debug and release) using qmake or cmake. This indicates to me stat by CMakeLists.txt file is good.
Using my static build and qmake, both release and debug builds of my project are fine. This indicates to me that the static build is good.
If I use cmake, then the release build is good, but the debug build fails. It looks like it is not seeing the debug libraries. I figure it is my problem or everyone would be complaining, but cant figure out why this is. The link errors are numerous, Here is an example:
Qt6Core.lib(qpluginloader.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in QWindowsVistaStylePlugin_init.cpp.obj Qt6Core.lib(qpluginloader.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in QWindowsVistaStylePlugin_init.cpp.obj Qt6Core.lib(qglobal.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in QWindowsVistaStylePlugin_init.cpp.obj Qt6Core.lib(qglobal.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in QWindowsVistaStylePlugin_init.cpp.obj
Does anyone have any ideas on what I need to do to fix this for cmake?
-
Hi,
From very old memory, it seems that you have your plugins linked against the release VS runtime while the rest is against the debug VS runtime.
[edit: corrected information SGaist]
-
Hi,
From very old memory, it seems that you have your plugins linked against the release VS runtime while the rest is against the debug VS runtime.
[edit: corrected information SGaist]
@SGaist I apologise but don't know what you mean. The reference to plugins just happens to be the first of hundreds of errors. I do not knowingly specify plugins anywhere. The qtcreator build system just seems to handle them under the hood. But since it all builds fine with qmake, why wouldn't it build the same with cmake?
-
Sorry, I made some errors. Post fixed.
From the looks of it, it seems that cmake tries to link the release plugins even when using the debug build.
I would check the cmake files that are handling that in your static installation.
-
Sorry, I made some errors. Post fixed.
From the looks of it, it seems that cmake tries to link the release plugins even when using the debug build.
I would check the cmake files that are handling that in your static installation.
@SGaist I agree. It does look like cmake is using release plugins in debug builds. But you say "check the cmake files that are handling this in your static installation". What files would these be? What am I looking for? It is all PFM to me.
I am wondering if this cmake stuff is really mature enough to be used. qmake still seems a better choice.
-
The files in the lib/cmake folder of your static installation.
There might be glitches. Static builds are not that common as the related requirements to respect the GPL/LGPL licences make the dynamic build more interesting.
-
The files in the lib/cmake folder of your static installation.
There might be glitches. Static builds are not that common as the related requirements to respect the GPL/LGPL licences make the dynamic build more interesting.
@SGaist Well there are 944 files in the cmake directory and sub-directories. It is like looking for a needle in a haystack. Unless you can answer specifically what needs to be changed or have any idea why it is not right in the first place, I would respectfully ask you to stop answering and leave the space open for someone who could actually help me with this.
-
I am using qtcreator. I have made a static build of 6.2.0 on windows.
If I use the downloadable DLL release, I can build my project perfectly (both debug and release) using qmake or cmake. This indicates to me stat by CMakeLists.txt file is good.
Using my static build and qmake, both release and debug builds of my project are fine. This indicates to me that the static build is good.
If I use cmake, then the release build is good, but the debug build fails. It looks like it is not seeing the debug libraries. I figure it is my problem or everyone would be complaining, but cant figure out why this is. The link errors are numerous, Here is an example:
Qt6Core.lib(qpluginloader.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in QWindowsVistaStylePlugin_init.cpp.obj Qt6Core.lib(qpluginloader.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in QWindowsVistaStylePlugin_init.cpp.obj Qt6Core.lib(qglobal.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in QWindowsVistaStylePlugin_init.cpp.obj Qt6Core.lib(qglobal.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in QWindowsVistaStylePlugin_init.cpp.obj
Does anyone have any ideas on what I need to do to fix this for cmake?
@ChortleMortal
Well I found out what the problem was. Since 6.2.1 was just released I thought I would make the static libraries for that. I did it exactly the way I did it before, and got exactly the same problem with the debug build. But then I noticed that the instruction at the end of the 'configure' operation had changed from before. Previously it said after the configure and build to run cmake --install . Now it says, run ninja install . I did that, and hey-presto the build works. Still incomprehensible why the new would differ from the old way. But I am moving on, now.Also, if anyone is having the same problem as myself, this is what I used to configure the system:
configure -static -debug-and-release -no-pch -confirm-license -prefix "C:\Qt\6.2.1\static" -opensource -mp -nomake examples -nomake tests -no-icu -no-opengl -no-openssl -skip qtwayland -skip qtquick3d -skip qtquickcontrols2 -skip qtquicktimeline -skip qtshadertools -skip qtdeclarative -skip qttools -skip qtdoc -skip qttranslations -skip qt3d -skip qt5compat -skip qtcharts -skip qtcoap -skip qtdatavis3d -skip qtlottie -skip qtmqtt -skip qtopcua -skip qtscxml -skip qtvirtualkeyboard -skip qtmultimedia -skip qtwebengine -skip qtwebview