Qt Static Build 'Runtime Mismatch' MSVC
-
After a few different tries I followed this tutorial to statically compile Qt. The tutorial linked above seemed to work more than any other tutorial or attempt(s) I've had. I run into one issue with this tutorial though. Rather than getting unresolved externals etc I get 'RuntimeLibrary Mismatch'
Exact errorsSeverity Code Description Project File Line Suppression State Error LNK1319 1 mismatches detected Uploader C:\Users\Contempt\source\repos\Uploader\x64\Debug\Uploader.exe 1 Warning LNK4098 defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library Uploader C:\Users\Contempt\source\repos\Uploader\Uploader\LIBCMTD.lib(initializers.obj) 1 Error LNK2038 mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in App.obj Uploader C:\Users\Contempt\source\repos\Uploader\Uploader\qtmaind.lib(qtmain_win.obj) 1
Picture
Notes:
Using MSVC 2017
Qt 5.9 -
Hi,
You are trying to link libraries using two different runtime, that won't work. Either build everything linking to the static runtime or everything with the dynamic runtime but you can't mix both.
-
Do you have any other dependency ?
Did you cleanup everything from your project before starting to use your self-built Qt ?
Did you try to build a default application with Qt Creator using your static Qt ?
-
@SGaist No I am installing Qt Creator right now to test that, but I fresh installed Qt Source so I assume it is cleaned? No other dependencies.
//Edit
I can dynamically compile with my static build, yet when I change from MDd to MTd I get the RuntimeLib error. Is this a bad sign? -
Are you sure you are using your self-built Qt ?
-
When you build Qt statically, did you do any modification to use the static runtime ?
Otherwise, even if you build Qt statically, it uses the dynamic runtime.
-
@SGaist I believe so. I used configure.bat with static option and compiled with NMAKE. I did everything the tutorial said, but the tutorial was for an older (5.7) Version of Qt does this change anything? Is there an official Qt Static Compilation tutorial?
-
Turns out my Microsoft Visual Studio was using the wrong Qt version (Not my static one) after changing it to the right one I no longer get MT mis matches (in fact if I try to compile with MD I get mismatches :) ), but I now have 159 unresolved externals. Have I done something wrong?
-
What are these externals ?