我正在使用 Intel C++ 13.0.1.119 Build 20121008 for IA-32 在 Visual Studio 2012 的 Windows 上运行。我一直遇到链接器错误问题,并将其缩小到选项/Qcheck-pointers:rw
。每当我使用 编译时/Qcheck-pointers:rw
,都会出现以下错误:
1> xilink: executing 'link'
1>libcmt.lib(invarg.obj) : error LNK2005: "void __cdecl _invalid_parameter(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" (?_invalid_parameter@@YAXPBG00II@Z) already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: "void __cdecl _invoke_watson(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" (?_invoke_watson@@YAXPBG00II@Z) already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: __call_reportfault already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: __get_invalid_parameter_handler already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: __initp_misc_invarg already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: __invalid_parameter already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: __set_invalid_parameter_handler already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: ___pInvalidArgHandler already defined in LIBCMTD.lib(invarg.obj)
1>libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Y:\...\ : fatal error LNK1169: one or more multiply defined symbols found
我找到了这篇文章,表明它可以通过关闭检查无维数组使用来解决/Qcheck-pointers-undimensioned-
。但是,这似乎没有任何效果,并且我得到了相同的链接器错误。
有谁知道如何解决这个链接问题?
更新:根据 Eric Shiyin Kang 的建议,我离开/Qcheck-pointers:rw
并/Qcheck-pointers-undimensioned-
在命令行上,但添加/NODEFAULTLIB:libcmt.lib
为链接器命令。这导致我得到一个不同的链接器错误:
1> xilink: executing 'link'
1>libcpmt.lib(nothrow.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in libcpmtd.lib(stdthrow.obj)
1>libcpmt.lib(nothrow.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MTd_StaticDebug' in libcpmtd.lib(stdthrow.obj)
1>Y:\..\.exe : fatal error LNK1319: 2 mismatches detected
更新 2: 这是完整的编译器命令行:
/RTCc /GS /Qcheck-pointers:rw /debug:expr-source-pos /W5 /Gy /Zc:wchar_t /I"\..\include\gtest" /I"\..\include\" /Zi /Od /Qintel-extensions- /Fd"Debug\vc110.pdb" /fp:precise /D "_VARIADIC_MAX=10" /D "_MBCS" /Qipo /Zc:forScope /RTC1 /Qcheck-pointers-undimensioned- /Gd /MTd /Fa"Debug\" /EHsc /nologo /Za /Fo"Debug\" /Fp"Debug\Project2.pch"
这是完整的链接器命令行:
/OUT:"\..\Project2.exe" /MANIFEST /NXCOMPAT /PDB:"\..\Project2.pdb" /DYNAMICBASE "gtestd.lib" "gtest_maind.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X86 /OPT:REF /SAFESEH / /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Debug\Project2.exe.intermediate.manifest" /OPT:ICF /NOLOGO /LIBPATH:"\..\include\gtest\debug_build" /TLBID:1 /NODEFAULTLIB:libcmt.lib
我正在使用 GTest 库并正在使用多线程调试运行时库来匹配 GTest。