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. Building qt from source (debug) error LNK2038
Forum Updated to NodeBB v4.3 + New Features

Building qt from source (debug) error LNK2038

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 653 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 17 Aug 2023, 01:48 last edited by
    #1

    Hey,

    So I am trying to build qt from source in debug. Whenever I try to build release, everything is fine but whenever I build in debug, I get 2 errors which repeat for many files and 1 error at the very end. The 2 errors are:

    error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2'
    error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug'
    

    and the single end error is:

    LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
    

    and this happens with every single variant of the configure/build command I could think of. here are 2 version:

    cd <QTsrc>
    mkdir build && cd build
    ..\configure.bat -debug -prefix "D:\Libraries\Qt\6.6.0\BuildDebug" -skip webengine -nomake tests -nomake examples -- -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG="/Zi /Ob0 /Od /RTC1 /MDd"&& cmake --build . --parallel && cmake --install .
    

    and

    cd <QTsrc>
    mkdir build && cd build
    cmake .. -G Ninja -DCMAKE_PREFIX_PATH="D:\Libraries\Qt\6.6.0\BuildDebug" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG="/Zi /Ob0 /Od /RTC1 /MDd" -DCMAKE_C_FLAGS_DEBUG="/Zi /Ob0 /Od /RTC1 /MDd" -DWEBENGINE_SKIP=ON -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF && cmake --build . --parallel && cmake --install .
    

    Many thanks in advance.

    C 1 Reply Last reply 17 Aug 2023, 04:18
    0
    • N Norzka
      17 Aug 2023, 01:48

      Hey,

      So I am trying to build qt from source in debug. Whenever I try to build release, everything is fine but whenever I build in debug, I get 2 errors which repeat for many files and 1 error at the very end. The 2 errors are:

      error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2'
      error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug'
      

      and the single end error is:

      LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
      

      and this happens with every single variant of the configure/build command I could think of. here are 2 version:

      cd <QTsrc>
      mkdir build && cd build
      ..\configure.bat -debug -prefix "D:\Libraries\Qt\6.6.0\BuildDebug" -skip webengine -nomake tests -nomake examples -- -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG="/Zi /Ob0 /Od /RTC1 /MDd"&& cmake --build . --parallel && cmake --install .
      

      and

      cd <QTsrc>
      mkdir build && cd build
      cmake .. -G Ninja -DCMAKE_PREFIX_PATH="D:\Libraries\Qt\6.6.0\BuildDebug" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG="/Zi /Ob0 /Od /RTC1 /MDd" -DCMAKE_C_FLAGS_DEBUG="/Zi /Ob0 /Od /RTC1 /MDd" -DWEBENGINE_SKIP=ON -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF && cmake --build . --parallel && cmake --install .
      

      Many thanks in advance.

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 17 Aug 2023, 04:18 last edited by
      #2

      Don't set the CMAKE_BUILD_TYPE and all the cxx flags - you most likely mix some stuff up. Let confnfigure.bar build all the stuff for you without those settings. Then you will get the correct Qt debug and release dlls.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      N 1 Reply Last reply 17 Aug 2023, 10:49
      0
      • C Christian Ehrlicher
        17 Aug 2023, 04:18

        Don't set the CMAKE_BUILD_TYPE and all the cxx flags - you most likely mix some stuff up. Let confnfigure.bar build all the stuff for you without those settings. Then you will get the correct Qt debug and release dlls.

        N Offline
        N Offline
        Norzka
        wrote on 17 Aug 2023, 10:49 last edited by
        #3

        @Christian-Ehrlicher well thats what I was trying before, just using the -debug flag without the cmake flags. and that would result in the same error

        C 1 Reply Last reply 17 Aug 2023, 11:05
        0
        • N Norzka
          17 Aug 2023, 10:49

          @Christian-Ehrlicher well thats what I was trying before, just using the -debug flag without the cmake flags. and that would result in the same error

          C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 17 Aug 2023, 11:05 last edited by
          #4

          @Norzka said in Building qt from source (debug) error LNK2038:

          @Christian-Ehrlicher well thats what I was trying before, just using the -debug flag without the cmake flags. and that would result in the same error

          Don't set debug at all. Configure will do the right thing.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          N 1 Reply Last reply 17 Aug 2023, 11:49
          0
          • C Christian Ehrlicher
            17 Aug 2023, 11:05

            @Norzka said in Building qt from source (debug) error LNK2038:

            @Christian-Ehrlicher well thats what I was trying before, just using the -debug flag without the cmake flags. and that would result in the same error

            Don't set debug at all. Configure will do the right thing.

            N Offline
            N Offline
            Norzka
            wrote on 17 Aug 2023, 11:49 last edited by
            #5

            @Christian-Ehrlicher well I want debug so I can easier debug my program, and whenever I run the configure command without the debug flag, it defaults to -debug-and-release which causes the same error

            C 1 Reply Last reply 17 Aug 2023, 15:44
            0
            • N Norzka
              17 Aug 2023, 11:49

              @Christian-Ehrlicher well I want debug so I can easier debug my program, and whenever I run the configure command without the debug flag, it defaults to -debug-and-release which causes the same error

              C Offline
              C Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 17 Aug 2023, 15:44 last edited by
              #6

              Delete your build directory and start over. Don't specify any compiler flags - its' not needed.
              Also why don't you use pre-compiled Qt libs?

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              N 1 Reply Last reply 17 Aug 2023, 18:08
              0
              • C Christian Ehrlicher
                17 Aug 2023, 15:44

                Delete your build directory and start over. Don't specify any compiler flags - its' not needed.
                Also why don't you use pre-compiled Qt libs?

                N Offline
                N Offline
                Norzka
                wrote on 17 Aug 2023, 18:08 last edited by
                #7

                @Christian-Ehrlicher I have tried that too. I get the same error. And I could, but I get a runtime error, something about string conversion, looking online suggests that it is to do with QT and your project being compiled with different STLs, so that's what made me try to build from source. The thing is since I can build release, I can work on projects using QT, but if I run into some problem, I have to debug without using the Visual Studio debugger.

                C 1 Reply Last reply 17 Aug 2023, 18:20
                0
                • N Norzka
                  17 Aug 2023, 18:08

                  @Christian-Ehrlicher I have tried that too. I get the same error. And I could, but I get a runtime error, something about string conversion, looking online suggests that it is to do with QT and your project being compiled with different STLs, so that's what made me try to build from source. The thing is since I can build release, I can work on projects using QT, but if I run into some problem, I have to debug without using the Visual Studio debugger.

                  C Offline
                  C Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 17 Aug 2023, 18:20 last edited by
                  #8

                  @Norzka said in Building qt from source (debug) error LNK2038:

                  I have tried that too. I get the same error. And I could, but I get a runtime error, something about string conversion, looking online suggests that it is to do with QT and your project being compiled with different STLs, so that's what made me try to build from source.

                  From what are you talking? Using your Qt or the pre-compiled ones?

                  Use the pre-compiled ones with a proper CMakeLists.txt for your project and you won't get problems with different runtimes. Somehwere you mix /MT(d) with /MD(d) which must not be done.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  1

                  1/8

                  17 Aug 2023, 01:48

                  • Login

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