Tag Archives: error LNK2038

error LNK2038: mismatch detected for ‘RuntimeLibrary’: value ‘MDd_DynamicDebug’ does not match value ‘MTd_StaticDebug’

There are a bunch of errors in VS2012 C++ compilation today:

1  1 >   Generating code...
 2  1 >Code.obj : error LNK2005: " public: __thiscall std::_Container_base12::_Container_base12(void) " (?? 0_Container_base12@std@@QAE@XZ) 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) 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) is already defined in msvcprtd.lib(MSVCP110D.dll)
 5  1 > IOCP_Socket.lib(CLog.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' Mismatch for value 'MTd_StaticDebug' (in Code.obj)
 6  1 > IOCP_Socket.lib(TcpServer.obj) : error LNK2038: Detected mismatch for 'RuntimeLibrary': value 'MDd_DynamicDebug' does not match value 'MTd_StaticDebug'(Code. obj)
 7  1 > IOCP_Socket.lib(stdafx.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' does not match value 'MTd_StaticDebug' (in Code.obj)
 8  1 > IOCP_Socket.lib (TcpSrvException.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' does not match value 'MTd_StaticDebug' (in Code.obj)
 9  1> IOCP_Socket.lib(TcpReceiveContext.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' does not match value 'MTd_StaticDebug' (in Code.obj)
 10  1 > IOCP_Socket.lib(TcpSendContext.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' does not match value 'MTd_StaticDebug' (in 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: Detected mismatch for 'RuntimeLibrary': value 'MDd_DynamicDebug' Mismatch value "MTd_StaticDebug" (in Code.obj)
 13  1 >IOCP_Socket.lib(MemoryBlock.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' does not match value 'MTd_StaticDebug' (in Code.obj)
 14  1 > IOCP_Socket.lib(ContextStack.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' does not match 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) is already 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) is already 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) is already 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) is already defined in Code.obj
 19  1 >msvcprtd.lib(MSVCP110D.dll) : error LNK2005: " void __cdecl std::_Xbad_alloc(void) " (?_Xbad_alloc@std@@YAXXZ) is already 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) is already 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) is already 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) is already 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) already 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 is already defined in LIBCMTD.lib(fclose.obj)
 28  1 > MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _fflush is already defined in LIBCMTD.lib(fflush .obj)
 29  1 > MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _printf is already defined in LIBCMTD.lib(printf.obj)
 30  1 > MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _vprintf is already defined Define 31  1 > in LIBCMTD.lib(vprintf.obj)
MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: __vsnprintf_s is already defined in LIBCMTD.lib(vsnprnc.obj)
 32  1 > MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _vsprintf_s is already defined in LIBCMTD.lib(vsnprnc.obj ) 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 in LIBCMTD 35  defined in .lib(memcpy_s.obj)
 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) already 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) 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) has been 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@@AAAAAV0@ABV0@@Z) is already defined in LIBCMTD.lib(typinfo.obj)
 41  1 >LINK : warning LNK4098: default library "MSVCRTD" conflicts with other libraries ; please use / NODEFAULTLIB:library
 42  1 >E:\Projects\C++ \IOCP_Socket\Debug\Test.exe : fatal error LNK1169: one or more multiply defined symbols were found
 43 ========== Generated : 0 successful, 1 failed , 0 latest , 0 skipped ==========

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

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

All settings are the same. Multi-threaded debugging (/MTd)