每當我在Release中構建代碼時,它都會編譯並運行正常。但是,當我切換到Debug時,出現了一些我似乎無法弄清楚的錯誤。構建調試時鏈接錯誤
swift.lib(scene.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>swift.lib(fileio.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>swift.lib(mesh_utils.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>swift.lib(object.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>swift.lib(mesh.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>swift.lib(pair.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>swift.lib(lut.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
1>msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]) already defined in main.obj
1>msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: void __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@QAEXXZ) already defined in main.obj
1>msvcprt.lib(MSVCP100.dll) : error LNK2005: "bool __cdecl std::uncaught_exception(void)" ([email protected]@@YA_NXZ) already defined in libcpmtd.lib(uncaught.obj)
1>msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]) already defined in main.obj
1>msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: __int64 __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,__int64)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]) already defined in main.obj
一堆更多的,然後......
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: __thiscall std::exception::exception(char const * const &)" ([email protected]@@[email protected]@Z) already defined in LIBCMTD.lib(stdexcpt.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" ([email protected]@@[email protected]) already defined in LIBCMTD.lib(stdexcpt.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: __thiscall std::bad_cast::bad_cast(char const *)" ([email protected]@@[email protected]@Z) already defined in LIBCMTD.lib(stdexcpt.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" ([email protected]@@[email protected]@@Z) already defined in LIBCMTD.lib(stdexcpt.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _memmove already defined in LIBCMTD.lib(memmove.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _fgetc already defined in LIBCMTD.lib(fgetc.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _fputc already defined in LIBCMTD.lib(fputc.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _ungetc already defined in LIBCMTD.lib(ungetc.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __lock_file already defined in LIBCMTD.lib(_file.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __unlock_file already defined in LIBCMTD.lib(_file.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _fflush already defined in LIBCMTD.lib(fflush.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _setvbuf already defined in LIBCMTD.lib(setvbuf.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strncmp already defined in LIBCMTD.lib(strncmp.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _memcpy_s already defined in LIBCMTD.lib(memcpy_s.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _fwrite already defined in LIBCMTD.lib(fwrite.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _fgetpos already defined in LIBCMTD.lib(fgetpos.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __fseeki64 already defined in LIBCMTD.lib(fseeki64.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _fsetpos already defined in LIBCMTD.lib(fsetpos.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _fclose already defined in LIBCMTD.lib(fclose.obj)
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" ([email protected]@[email protected]@@Z) already defined in LIBCMTD.lib(typinfo.obj)
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" ([email protected]@[email protected]@@Z) already defined in LIBCMTD.lib(typinfo.obj)
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>C:\...\: fatal error LNK1169: one or more multiply defined symbols found
我同時使用SWIFT和操作碼庫。我在C++中有「運行時庫」字段 - >代碼生成對於所有3個項目(我的主項目,swift,操作碼)都是相同的。我已經嘗試將它們全部設置爲\ MT,並且全部設置爲\ MD以用於調試模式,但都不起作用。實際上,當它在Release中成功構建時,我必須將Opcode和我的活動項目設置爲\ MD(swift可以是\ md或\ mt,它仍然可以構建)。我不是很瞭解運行時庫很好鏈接...所以如果這是問題,你可以嘗試明確嗎?
我也去找_ITERATOR_DEBUG_LEVEL,但找不到它。我應該在哪裏找到它來改變它?我無法在源代碼中找到它。我沒有在項目屬性中看到它,但是我只是沒有在屬性中尋找正確的位置,這是完全合理的。
顯然人們有錯誤匹配的字符集有類似的錯誤。我已經嘗試將它們全部設置爲多個,並全部設置爲unicode。這似乎沒有任何影響。
目前,我的活動項目只有swift.lib作爲附加依賴項。我有opcode.dll和opcode_d.dll,所以我不會靜態鏈接這些。
在預處理器下C/C++的設置,我有以下預處理器定義:
操作碼:
WIN32
_DEBUG
_WINDOWS
_USRDLL
OPCODE_EXPORTS
SWIFT:
_DEBUG
WIN32
_LIB
LOOKUP_TABLE_5_625
活動項目:
WIN32
_DEBUG
_CONSOLE
如果需要,我可以提供更多信息。謝謝你的幫助。
我沒有在那裏看到_ITERATOR_DEBUG_LEVEL宏,但我更新了每個項目中的宏的問題。 – Sterling 2013-04-10 21:15:07