Tag Archives: Error lnk2038

[Solved] error LNK2038: Detected mismatch of “RuntimeLibrary”: The value “MDd_DynamicDebug” does not match the value “MTd_StaticDebug”

A bunch of errors appeared in VS2012 C++ compilation today:

1  1 >   Code generation...
 2  1 >Code.obj: error LNK2005: " public: __thiscall std::_Container_base12::_Container_base12(void) " (?? 0_Container_base12@std@@QAE@XZ) is already in msvcprtd. Defined in lib(MSVCP110D.dll)
 3  1 >Code.obj: error LNK2005: " public: __thiscall std::_Container_base12::~_Container_base12(void) " (?? 1_Container_base12@std@@QAE@XZ) is already in msvcprtd. Defined in lib(MSVCP110D.dll)
 4  1 >Code.obj: error LNK2005: " public: void __thiscall std::_Container_base12::_Orphan_all(void) " (?_Orphan_all@_Container_base12@std@@QAEXXZ) has been defined in msvcprtd.lib(MSVCP110D.dll)
 5  1 > IOCP_Socket.lib(CLog.obj): error LNK2038: mismatch detected for "RuntimeLibrary": value "MDd_DynamicDebug" Mismatched value "MTd_StaticDebug" (in Code.obj)
 6  1 > IOCP_Socket.lib(TcpServer.obj): error LNK2038: mismatch detected for "RuntimeLibrary": The value "MDd_DynamicDebug" does not match the value "MTd_StaticDebug" (Code. obj)
 7  1 > IOCP_Socket.lib(stdafx.obj): error LNK2038: mismatch detected for "RuntimeLibrary": The value "MDd_DynamicDebug" does not match the value "MTd_StaticDebug" (Code.obj)
 8  1 > IOCP_Socket.lib (TcpSrvException.obj): error LNK2038: mismatch detected for "RuntimeLibrary": The value "MDd_DynamicDebug" does not match the value "MTd_StaticDebug" (in Code.obj)
 9  1> IOCP_Socket.lib(TcpReceiveContext.obj): error LNK2038: mismatch detected for "RuntimeLibrary": The value "MDd_DynamicDebug" does not match the value "MTd_StaticDebug" (in Code.obj)
 10  1 > IOCP_Socket.lib(TcpSendContext.obj) : error LNK2038: mismatch detected for "RuntimeLibrary": The value "MDd_DynamicDebug" does not match the value "MTd_StaticDebug" (Code.obj)
 11  1 > IOCP_Socket.lib(AcceptContext.obj): error LNK2038: "RuntimeLibrary" detected Mismatch for: value "MDd_DynamicDebug" does not match value "MTd_StaticDebug" (in Code.obj)
 12  1 > IOCP_Socket.lib(OperateContext.obj): error LNK2038: mismatch detected for "RuntimeLibrary": value "MDd_DynamicDebug" Does not match the value "MTd_StaticDebug" (in Code.obj)
 13  1 >IOCP_Socket.lib(MemoryBlock.obj): error LNK2038: mismatch detected for "RuntimeLibrary": The value "MDd_DynamicDebug" does not match the value "MTd_StaticDebug" (in Code.obj)
 14  1 > IOCP_Socket.lib(ContextStack.obj): error LNK2038: mismatch detected for "RuntimeLibrary": The value "MDd_DynamicDebug" does not match the value "MTd_StaticDebug" (in Code.obj)
 15  1 >msvcprtd.lib(MSVCP110D.dll): error LNK2005: " void __cdecl std:: _Debug_message(wchar_t const *,wchar_t const *,unsigned int) " (? _Debug_message@std@@YAXPB_W0I@Z) has been defined in libcpmtd.lib(stdthrow.obj)
 16  1 >msvcprtd.lib(MSVCP110D.dll): error LNK2005: " public: __thiscall std::_Container_base12::_Container_base12(void) " (??0_Container_base12@std@@QAE@XZ) has been defined in Code.obj
 17  1 >msvcprtd.lib(MSVCP110D.dll): error LNK2005: " public: __thiscall std::_Container_base12::~_Container_base12(void) " (?? 1_Container_base12@std@@QAE@XZ) has been defined in Code.obj
 18  1 >msvcprtd.lib(MSVCP110D.dll): error LNK2005: " public: void __thiscall std::_Container_base12::_Orphan_all(void) " (? _Orphan_all @_Container_base12@std@@QAEXXZ) has been defined in Code.obj
 19  1 >msvcprtd.lib(MSVCP110D.dll): error LNK2005: " void __cdecl std::_Xbad_alloc(void) " (?_Xbad_alloc@std@@YAXXZ) has been defined in libcpmtd.lib(xthrow.obj)
 20  1 >msvcprtd.lib(MSVCP110D.dll): error LNK2005: " void __cdecl std::_Xlength_error(char const *) " (? _Xlength_error @std@@YAXPBD@Z) has been defined in libcpmtd.lib(xthrow.obj)
 21  1 >msvcprtd.lib(MSVCP110D.dll): error LNK2005: " void __cdecl std::_Xout_of_range(char const *) " (? _Xout_of_range@std@@YAXPBD@Z) has been defined in libcpmtd.lib(xthrow.obj)
 22  1 >msvcprtd.lib(MSVCP110D.dll): error LNK2005: " char const * __cdecl std::_Syserror_map(int) " ( ?_Syserror_map@std@@YAPBDH@Z) has been defined in
 libcpmtd.lib(syserror.obj) 23  1 >msvcprtd.lib(MSVCP110D.dll): error LNK2005: " char const * __cdecl std::_Winerror_map(int) " ( ? _Winerror_map@std@@YAPBDH@Z) has been defined in
 libcpmtd.lib(syserror.obj) 24  1 >msvcprtd.lib(MSVCP110D.dll): error LNK2005: " public: __thiscall std::_Lockit::_Lockit(int ) " (?? 0_Lockit@std@@QAE@H@Z) has been defined in libcpmtd.lib(xlock.obj)
 25  1 >msvcprtd.lib(MSVCP110D.dll): error LNK2005: " public: __thiscall std:: _Lockit::~_Lockit(void) " (??1_Lockit@std@@QAE@XZ) is already defined in libcpmtd.lib(xlock.obj)
 26  1 > MSVCRTD.lib(MSVCR110D.dll): error LNK2005: _memmove is already defined in LIBCMTD.lib(memmove.obj)
 27  1 > MSVCRTD.lib(MSVCR110D.dll): error LNK2005: _fclose already defined in LIBCMTD.lib(fclose.obj)
 28  1 > MSVCRTD.lib(MSVCR110D.dll): error LNK2005: _fflush already defined in LIBCMTD.lib(fflush .obj)
 29  1 > MSVCRTD.lib(MSVCR110D.dll): error LNK2005: _printf already defined in LIBCMTD.lib(printf.obj)
 30  1 > MSVCRTD.lib(MSVCR110D.dll): error LNK2005: _vprintf already defined Defined in LIBCMTD.lib(vprintf.obj)
 31  1 >MSVCRTD.lib(MSVCR110D.dll): error LNK2005: __vsnprintf_s already defined in LIBCMTD.lib(vsnprnc.obj)
 32  1 > MSVCRTD.lib(MSVCR110D.dll): error LNK2005: _vsprintf_s already defined in LIBCMTD.lib(vsnprnc.lib(vsnprnc) ) Defined in
 33  1 > MSVCRTD.lib(MSVCR110D.dll): error LNK2005: __invalid_parameter is already defined in LIBCMTD.lib(invarg.obj)
 34  1 > MSVCRTD.lib(MSVCR110D.dll): error LNK2005: _memcpy_s is already defined in LIBCMTD .lib(memcpy_s.obj) is defined in
 35  1 > MSVCRTD.lib(MSVCR110D.dll): error LNK2005: _strncpy_s is already defined in LIBCMTD.lib(strncpy_s.obj)
 36  1 >MSVCRTD.lib(MSVCR110D.dll): error LNK2005: "public: virtual __thiscall std::exception::~exception(void) " (?? 1exception@std@@UAE@XZ) has been defined in LIBCMTD.lib(stdexcpt.obj)
 37  1 >MSVCRTD.lib(MSVCR110D.dll ): error LNK2005: " public: virtual char const * __thiscall std::exception::what(void)const " (? what@exception@std@@UBEPBDXZ) is already defined in LIBCMTD.lib(stdexcpt.obj)
 38  1 > MSVCRTD.lib(MSVCR110D.dll): error LNK2005: __CrtDbgReportW is already defined in LIBCMTD.lib(dbgrptw.obj)
 39  1 >MSVCRTD.lib(ti_inst.obj): error LNK2005: " private: __thiscall type_info::type_info( class type_info const &) " (??0type_info@@AAE@ABV0@@Z) is already defined in LIBCMTD.lib(typinfo.obj)
 40  1 >MSVCRTD.lib(ti_inst.obj): error LNK2005: " private: class type_info & __thiscall type_info::operator=( class type_info const &) " (?? 4type_info@@AAEAAV0@ABV0@@Z) has been defined in LIBCMTD.lib(typinfo.obj)
 41  1 >LINK: warning LNK4098: The default library "MSVCRTD" conflicts with the use of other libraries ;Please use / NODEFAULTLIB:library
 42  1 >E:\Projects\C++ \IOCP_Socket\Debug\Test.exe: fatal error LNK1169: Found one or more multiple defined symbols
 43 ========== Generate : Success 0 , failure 1 , 0 latest , skip 0 ==========

Later, I checked it and found that it was a problem with the runtime library settings; the runtime library settings for several projects were different:

Project Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library

We are set on the line, like multi-threaded debugging (/ MTd)

Error lnk2038: detected “_ ITERATOR_ DEBUG_ Mismatched ‘level’ value of ‘0’

Problem description: the C++ program developed by Visual Studio 2010, after adding the h and CPP files of the third-party library, reported the following error when compiling and running:
Error LNK2038: “_ITERATOR_DEBUG_LEVEL” mismatches detected: value “0” mismatches value “2”Problem analysis: _ITERATOR_DEBUG_LEVEL is the system variable that records the compilation mode, 0 means that the current project is the Debug version, 2 means that the current project is the Release version.

Possible reasons 1:

Error 25 error LNK2038: Mismatch detected for "_ITERATOR_DEBUG_LEVEL": value "0" does not match value "2”

This problem is caused because the current project is the Debug version, but the library file referenced is the Release version.

“_ITERATOR_DEBUG_LEVEL” mismatch: value "2" does not match value "0"   

If the above problem is detected, then Release mode refers to Debug’s library file. This type of problem requires careful version matching when referring to files
Solution: Fix the lib file name in the attachment dependency. In Debug mode, you just use the file name of the Debug DLL, and in Release mode, you just use the Release DLL. (Debug mode DLL files usually have d, in, at the end of the file name)

Possible cause 2: Incorrect project property Settings, solution — “properties” — “C/C++–” Code generation — “runtime properties.
This property should be set to “multi-threaded debugging DLL (/MDd)” in Debug mode and” multi-threaded DLL (/MD) “in release mode. The above problem can also occur if the Settings are reversed.
Ending method: Just modify the runtime properties according to the schema.

Possible reason 3: If neither of the above reasons is true, the _ITERATOR_DEBUG_LEVEL variable may have been artificially assigned in the code.
For example, the basicexcel.cpp file contains the following statements:

#ifdef _DEBUG
#define _ITERATOR_DEBUG_LEVEL 0	// speedup iterator operations while debugging
#endif

The same problem may occur if _ITERATOR_DEBUG_LEVEL is set to 0 in Debug mode in order to speed up the program running in Debug mode, so that _ITERATOR_DEBUG_LEVEL values do not match in Debug mode.

Solution: Changing _ITERATOR_DEBUG_LEVEL to an appropriate value in the program can solve the problem.