Building qt from source (debug) error LNK2038
-
wrote on 17 Aug 2023, 01:48 last edited by
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.
-
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.
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.
-
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.
wrote on 17 Aug 2023, 10:49 last edited by@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
-
@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
@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.
-
@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.
wrote on 17 Aug 2023, 11:49 last edited by@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 -
@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 errorDelete 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? -
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?wrote on 17 Aug 2023, 18:08 last edited by@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.
-
@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.
@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.
1/8