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 errors

    Severity	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
    alt text

    Notes:
    Using MSVC 2017
    Qt 5.9


  • Lifetime Qt Champion

    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.



  • @SGaist That's what I tried to do. I followed the tutorial linked above which is suppose to ready Qt to be statically compiled (Multi-Threaded), yet I still receive that error.


  • Lifetime Qt Champion

    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?


  • Lifetime Qt Champion

    Are you sure you are using your self-built Qt ?



  • @SGaist Yes. I tried to use Qt creator to test, but it was crying about not finding CL (MSVC Compiler) and I couldn't be bothered to fix one error just to test another.



  • I really just need to know what file to change from MD to MT. I believe my build is statically compiled because it throws no (other) errors, but one file somewhere still says MD which prevents it from building.


  • Lifetime Qt Champion

    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?


  • Lifetime Qt Champion

    What are these externals ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.