2013-04-10 64 views
1

每当我在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 

如果需要,我可以提供更多信息。谢谢你的帮助。

回答

0

这听起来像你已经确保C运行时库(CRT)是所有项目一致的,这是首选的做法。由于它使用CRT的独立副本,因此对于您的DLL项目不那么重要。

下一步是查看项目设置的“预处理器”页面。您正在寻找可能在三个项目中发生冲突的预处理器(宏)定义。我相信你会在列表中找到_ITERATOR_DEBUG_LEVEL。

我不知道如何在StackOverflow上发布后续问题,但是您可以将您在每个项目中找到的宏定义添加到您的问题中。

+0

我没有在那里看到_ITERATOR_DEBUG_LEVEL宏,但我更新了每个项目中的宏的问题。 – Sterling 2013-04-10 21:15:07

相关问题