error LNK2038: 檢測到“RuntimeLibrary”的不匹配項: 值“MDd_DynamicDebug”不匹配值“MTd_StaticDebug”


今日VS2012 C++編譯出現一堆錯誤:

 1 1>  正在生成代碼...
 2 1>Code.obj : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) 已經在 msvcprtd.lib(MSVCP110D.dll) 中定義
 3 1>Code.obj : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) 已經在 msvcprtd.lib(MSVCP110D.dll) 中定義
 4 1>Code.obj : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) 已經在 msvcprtd.lib(MSVCP110D.dll) 中定義
 5 1>IOCP_Socket.lib(CLog.obj) : error LNK2038: 檢測到“RuntimeLibrary”的不匹配項: 值“MDd_DynamicDebug”不匹配值“MTd_StaticDebug”(Code.obj 中)
 6 1>IOCP_Socket.lib(TcpServer.obj) : error LNK2038: 檢測到“RuntimeLibrary”的不匹配項: 值“MDd_DynamicDebug”不匹配值“MTd_StaticDebug”(Code.obj 中)
 7 1>IOCP_Socket.lib(stdafx.obj) : error LNK2038: 檢測到“RuntimeLibrary”的不匹配項: 值“MDd_DynamicDebug”不匹配值“MTd_StaticDebug”(Code.obj 中)
 8 1>IOCP_Socket.lib(TcpSrvException.obj) : error LNK2038: 檢測到“RuntimeLibrary”的不匹配項: 值“MDd_DynamicDebug”不匹配值“MTd_StaticDebug”(Code.obj 中)
 9 1>IOCP_Socket.lib(TcpReceiveContext.obj) : error LNK2038: 檢測到“RuntimeLibrary”的不匹配項: 值“MDd_DynamicDebug”不匹配值“MTd_StaticDebug”(Code.obj 中)
10 1>IOCP_Socket.lib(TcpSendContext.obj) : error LNK2038: 檢測到“RuntimeLibrary”的不匹配項: 值“MDd_DynamicDebug”不匹配值“MTd_StaticDebug”(Code.obj 中)
11 1>IOCP_Socket.lib(AcceptContext.obj) : error LNK2038: 檢測到“RuntimeLibrary”的不匹配項: 值“MDd_DynamicDebug”不匹配值“MTd_StaticDebug”(Code.obj 中)
12 1>IOCP_Socket.lib(OperateContext.obj) : error LNK2038: 檢測到“RuntimeLibrary”的不匹配項: 值“MDd_DynamicDebug”不匹配值“MTd_StaticDebug”(Code.obj 中)
13 1>IOCP_Socket.lib(MemoryBlock.obj) : error LNK2038: 檢測到“RuntimeLibrary”的不匹配項: 值“MDd_DynamicDebug”不匹配值“MTd_StaticDebug”(Code.obj 中)
14 1>IOCP_Socket.lib(ContextStack.obj) : error LNK2038: 檢測到“RuntimeLibrary”的不匹配項: 值“MDd_DynamicDebug”不匹配值“MTd_StaticDebug”(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) 已經在 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) 已經在 Code.obj 中定義
17 1>msvcprtd.lib(MSVCP110D.dll) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) 已經在 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) 已經在 Code.obj 中定義
19 1>msvcprtd.lib(MSVCP110D.dll) : error LNK2005: "void __cdecl std::_Xbad_alloc(void)" (?_Xbad_alloc@std@@YAXXZ) 已經在 libcpmtd.lib(xthrow.obj) 中定義
20 1>msvcprtd.lib(MSVCP110D.dll) : error LNK2005: "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPBD@Z) 已經在 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) 已經在 libcpmtd.lib(xthrow.obj) 中定義
22 1>msvcprtd.lib(MSVCP110D.dll) : error LNK2005: "char const * __cdecl std::_Syserror_map(int)" (?_Syserror_map@std@@YAPBDH@Z) 已經在 libcpmtd.lib(syserror.obj) 中定義
23 1>msvcprtd.lib(MSVCP110D.dll) : error LNK2005: "char const * __cdecl std::_Winerror_map(int)" (?_Winerror_map@std@@YAPBDH@Z) 已經在 libcpmtd.lib(syserror.obj) 中定義
24 1>msvcprtd.lib(MSVCP110D.dll) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) 已經在 libcpmtd.lib(xlock.obj) 中定義
25 1>msvcprtd.lib(MSVCP110D.dll) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) 已經在 libcpmtd.lib(xlock.obj) 中定義
26 1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _memmove 已經在 LIBCMTD.lib(memmove.obj) 中定義
27 1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _fclose 已經在 LIBCMTD.lib(fclose.obj) 中定義
28 1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _fflush 已經在 LIBCMTD.lib(fflush.obj) 中定義
29 1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _printf 已經在 LIBCMTD.lib(printf.obj) 中定義
30 1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _vprintf 已經在 LIBCMTD.lib(vprintf.obj) 中定義
31 1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: __vsnprintf_s 已經在 LIBCMTD.lib(vsnprnc.obj) 中定義
32 1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _vsprintf_s 已經在 LIBCMTD.lib(vsnprnc.obj) 中定義
33 1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: __invalid_parameter 已經在 LIBCMTD.lib(invarg.obj) 中定義
34 1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _memcpy_s 已經在 LIBCMTD.lib(memcpy_s.obj) 中定義
35 1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: _strncpy_s 已經在 LIBCMTD.lib(strncpy_s.obj) 中定義
36 1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) 已經在 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) 已經在 LIBCMTD.lib(stdexcpt.obj) 中定義
38 1>MSVCRTD.lib(MSVCR110D.dll) : error LNK2005: __CrtDbgReportW 已經在 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) 已經在 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) 已經在 LIBCMTD.lib(typinfo.obj) 中定義
41 1>LINK : warning LNK4098: 默認庫“MSVCRTD”與其他庫的使用沖突;請使用 /NODEFAULTLIB:library
42 1>E:\Projects\C++\IOCP_Socket\Debug\Test.exe : fatal error LNK1169: 找到一個或多個多重定義的符號
43 ========== 生成: 成功 0 個,失敗 1 個,最新 0 個,跳過 0 個 ==========

后來查了下,是運行庫設置的問題; 幾個工程的 運行庫設置不一樣了:

項目屬性 -> 配置屬性 -> C/C++ -> 代碼生成 -> 運行庫

都設置一樣就行了 多線程調試(/MTd)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM