mismatch detected for CRT library - c++

I'm facing the following error message:
libcpmt.lib(stdhndlr.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in libcpmtd.lib(xlock.obj)
libcpmt.lib(stdhndlr.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MTd_StaticDebug' in mtu.obj
I have been searching over the internet but found nothing about CRT libraries being mismatched.
I have tried to define following preprocessor definition: _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH however it did not resolved my issue.
I'm trying to compile a Debug configuration (Release is compiling fine).
Project runtime library is being set to:
Multi-threaded Debug (/MTd)
How can I link a debug version of libcpmt.lib?

Related

How can i fix error LNK2038 after adding tinyxml2?

I have a project that compiles normally and i need to use tinyxml2 library in it, but when i add it there appears 2 linking errors
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'
i can't say for sure, but maybe thats msvc-only issue because i never was facing such problem in clang

How to link against static and dynamic libraries at the same time?

I am using QtCreator for my project, I need to link some libraries dynamically because of license and I have some larger static library available, but I use only a small portion from it. When I try it, I got an error mixing builds.
base.lib(base.thread_local_storage.obj):-1: error: LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in Updater.obj
I am using msvc2017-64. how to configure the .pro file to achieve this?
Your CRT-Bindings are in Mismatch.
Under Project > C/C++ All Options > Runtime Library
You need to change at least one of the libs to MT or MD so there won't be a mismatch anymore.
Here you will find the solution:
LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in file.obj
If you compile the libs with Visual Studio

LNK 2038: RuntimeLibrary mismatch when using #include <xxx>

so I have C++ code in a dll 'MyDll', which is PInvoked by a C# project. This setup has been working well. Recently I introduced a few instances of #include <> and now, whenever I try to compile in Debug mode, I get the LNK 2038 error:
1>SimConnect.lib(SimConnectClient.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in MyDll.obj
1>SimConnect.lib(commClient.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in MyDll.obj
1>SimConnect.lib(client.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in MyDll.obj
SimConnect.lib is a release version (I don't have the source code) and there fore, it's RuntimeLibrary's value is MD (Multit-hreaded DLL (release)). Now, according to several answers on SO I've already found, I changed my RuntimeLibrary to MD in the Debug configuration.
My problem is concretely that, even after changing the RuntimeLibrary on MyDll's project's properties to Multi-threaded Dll (MD) in the Debug configuration, I still get the exact same errors. Since I am getting the exact same error, the key part being
"... doesn't match value 'MDd_DynamicDebug' in MyDll.obj"
even though the project properties have been changed, I take this as a hint that I am probably not changing the RuntimeLibrary's value correctly?
Furthermore, the errors only pop up when I use #include <> (#include "xxx" is not a problem"). Whenever I comment out any #include <> the errors don't trouble me.
Could someone give me a hint about what I might be doing wrong?
It would be also interesting to know why using these #includes trigger the mismatch errors with SimConnect.

Mismatch Detected for RunTimeLibrary ( MD DLL )

I'm trying to build a Win32 C++ project (AccountBuilder) with a configuration type of Application.exe and a Runtime Library of 'Multi-threaded DLL (/MD)' with a link to a lib file of another Win32 C++ project (ReportGenerator) with a configuration type of Static Library .lib also with a Runtime Library of 'Multi-threaded DLL (/MD)' in all configurations for both projects. However, I receive the following error:
Error 1 error LNK2038: mismatch detected for 'RuntimeLibrary': value
'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in
Account.obj File: Rpf.ReportGenerator(ReportGenerator.obj) Project: AccountBuilder
Error 2 error LNK2038: mismatch detected for 'RuntimeLibrary': value
'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in
Account.obj File: Rpf.ReportGenerator(FileType.obj) Project: AccountBuilder
After reading other questions on the topic I thought to ensure that the runtime libraries match exactly and it seems they do. However, the project still will not build in Debug within VS 2012? What could I be missing? I've set the configuration for the Runtime Library to '/MD' for 'All Configurations' to no avail and attempted multiple rebuilds of both projects and manually deleting the intermediate obj files with no luck.

How can I avoid problems of compile environment such as _MSC_VER mismatch error? [duplicate]

I was converting my projects from VS2010 to VS2012.But I am getting an _MSC_VER linker error in certain projects. After a long surfing through google I found out that the issue is due to linking of a library created in VS2010 to VS2012.
How can I find out that which projectis causing the error?
Here I am quoting the error:
Error 6 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile2.obj) Projectname2
Error 15 error LNK2001: unresolved external symbol "private: static void __cdecl std::locale::facet::_Facet_Register(class std::locale::facet *)" (?_Facet_Register#facet#locale#std##CAXPAV123##Z) D:\ProjectLocation\Projectname1.lib(CppFile3.obj) Projectname2
Error 13 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile4.obj) Projectname2
Error 12 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile5.obj) Projectname2
Error 10 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile6.obj) Projectname2
Error 11 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile7.obj) Projectname2
Error 9 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile8.obj) Projectname2
Error 4 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile9.obj) Projectname2
Error 14 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile10.obj) Projectname2
Error 7 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile11.obj) Projectname2
Error 8 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile12.obj) Projectname2
Error 5 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile13.obj) Projectname2
TL;DR; Recompile all your old static-linked .lib files with current-compiler (VS2012, in OP's case).
You are trying to link objects compiled by different versions of the compiler. That's not supported in modern versions of VS, at least not if you are using the C++ standard library. Different versions of the standard library are binary incompatible and so you need all the inputs to the linker to be compiled with the same version. Make sure you re-compile all the objects that are to be linked.
The compiler error names the objects involved so the information the the question already has the answer you are looking for. Specifically it seems that the static library that you are linking needs to be re-compiled.
So the solution is to recompile Projectname1.lib with VS2012.
You can link to older .lib files only if:
If they are not static-linked, and come with an already compiled .dll file (or .exe file).
Or if the two standard-libraries are binary-compatible (which they are not in OP's case).
for each project in your solution make sure that
Properties > Config. Properties > General > Platform Toolset
is one for all of them,
v100 for visual studio 2010,
v110 for visual studio 2012
you also may be working on v100 from visual studio 2012
I was importing also some projects from VS2010 to VS 2012. I had the same errors. The errors disappeared when I set back Properties > Config. Properties > General > Platform Toolset to v100 (VS2010). That might not be the correct approach, however.
I upgraded from 2010 to 2013 and after changing all the projects' Platform Toolset, I need to right-click on the Solution and choose Retarget... to make it work.