Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. error LNK2038: mismatch detected for 'RuntimeLibrary' when trying to compile project with static built QT

error LNK2038: mismatch detected for 'RuntimeLibrary' when trying to compile project with static built QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++errorlnk2038visual studio
3 Posts 2 Posters 1.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Norzka
    wrote on 9 Aug 2023, 23:19 last edited by
    #1

    Hello,

    So I wanted to static link/compile my qt project, since it is only 1 exe. I followed a tutorial on how to compile from source and a blog.
    The configure command I used was: configure.bat -release -static -static-runtime -no-pch -opensource -confirm-license -prefix "D:\Libraries\Qt\6.6.0\Build-Static" -skip webengine -nomake tests -nomake examples. The actual configuring, building and installing worked fine. But It's when I actually try to compile in Visual Studio 2022 that the problem comes up. I set the project to be statically linked (so RuntimeLibrary = MultiThreaded).
    Here is an example error, it seems to say the same thing for every .lib and .obj file:
    Qt6Widgets.lib(qtabwidget.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj
    I do also want to add that if I set the project "RuntimeLibrary" to MultiThreaded DLL, the error shows the same except the values switch.

    J 1 Reply Last reply 10 Aug 2023, 05:17
    0
    • N Norzka
      9 Aug 2023, 23:19

      Hello,

      So I wanted to static link/compile my qt project, since it is only 1 exe. I followed a tutorial on how to compile from source and a blog.
      The configure command I used was: configure.bat -release -static -static-runtime -no-pch -opensource -confirm-license -prefix "D:\Libraries\Qt\6.6.0\Build-Static" -skip webengine -nomake tests -nomake examples. The actual configuring, building and installing worked fine. But It's when I actually try to compile in Visual Studio 2022 that the problem comes up. I set the project to be statically linked (so RuntimeLibrary = MultiThreaded).
      Here is an example error, it seems to say the same thing for every .lib and .obj file:
      Qt6Widgets.lib(qtabwidget.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj
      I do also want to add that if I set the project "RuntimeLibrary" to MultiThreaded DLL, the error shows the same except the values switch.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 10 Aug 2023, 05:17 last edited by
      #2

      @Norzka Are you sure you're using your staticaly build Qt?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      N 1 Reply Last reply 10 Aug 2023, 12:56
      0
      • J jsulm
        10 Aug 2023, 05:17

        @Norzka Are you sure you're using your staticaly build Qt?

        N Offline
        N Offline
        Norzka
        wrote on 10 Aug 2023, 12:56 last edited by
        #3

        It looks like it's statically building. When I go into the directory, inside the bin folder there is no dlls, when I do the lib /list some.lib, it shows how .obj files instead of .dll files. Weirdly enough, when I statically compile with the dynamic dll version of QT, it compiles fine, although it still requires the dlls.

        1 Reply Last reply
        0

        1/3

        9 Aug 2023, 23:19

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved