"Mismatch detected for RuntimeLibrary" when trying to statically compile with a static build of Qt



  • Hello everybody, this is my first post on Qt forum. I'm trying to compile and use a static build of Qt 5.11 compiled with MSVC on windows 10.
    What I did so far (using VS 2017 x64 native tools command prompt) :

    configure -static -release -platform win32-msvc -prefix F:\qt-everywhere-src-5.11.1\static_build -nomake examples -nomake tests
    nmake
    nmake install
    

    Before building, using this tutorial, I modified qt-everywhere-src-5.11.1\qtbase\mkspecs\msvc-desktop.conf and replaced every -MD by -MT

    Build process went fine. After that, I installed QtCreator 4.3.1 and set up a Qt kit using MSVC compiler and my newly built Qt version.
    I created a new default Qt project (with mainwindow.cpp and mainwindow.h). It compiled successfully with -MD flag (this is strange), but when I added :

    QMAKE_CXXFLAGS_RELEASE = -MT
    CONFIG += static
    

    to my .pro file, I get hundred of errors like this (this time compiler is using /MT flag) :

    qwindowsvistastyle.lib(main.obj) : error LNK2038: discordance détectée pour 'RuntimeLibrary' : la valeur 'MD_DynamicRelease' ne correspond pas à la valeur 'MT_StaticRelease' in main.obj
    

    and this for every Qt lib.
    So I'm wondering : I specified -static in configure step, I have all Qt libs in my static_build folder, but :

    • Qt projects compiles with /MD, not with /MT
    • I can't use other static libraries, because I have to use /MT, which is impossible because of Qt at this time.
      What is my mistake ?
      Thanks in advance,
      EinderJam


  • @EinderJam said in "Mismatch detected for RuntimeLibrary" when trying to statically compile with a static build of Qt:

    Before building, using this tutorial, I modified qt-everywhere-src-5.11.1\qtbase\mkspecs\msvc-desktop.conf and replaced every -MD by -MT
    Build process went fine.

    If you changed the Qt compilation flags at some point, did you clean out absolutely everything before rebuilding? Many times it seems bits get left over which have been compiled with previous flags.


  • Banned

    This post is deleted!

Log in to reply
 

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