msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: class std::basic_ostream ...

本文介绍了解决在使用Visual Studio编译项目时遇到的LNK2005错误的方法。该错误通常是因为CRT和C++标准库的选择不一致导致的。文章提供了具体的配置步骤来帮助开发者调整编译器设置。
Error:         
msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: class std::basic_ostream ... 


Solution:

This looks like you've got a mismatch in your choice of C Runtime and C++ Standard Libraries.

You can choose between the static (.lib) or shared (DLL) versions of these using the compiler switches/MT/MTd/MD or /MDdMT variants indicate the static libraries, and MD the shared. The d appendix indicates the debug versions of each.

These can be set in Visual Studio by going to Project => Properties => Configuration Properties => C/C++ => Code Generation => Runtime Library

The problem appears to be that your project uses /MDand /MDd, but that GMock and Gtest were built with/MT and /MTd. You need to recompile GMock/Gtest with the /MD and /MDd flags, or change yours to /MTand /MTd.



I had similar problem: Solution: Release version Properties: configuration properties>c/c++>General>Warning level>level4(/W4) Properties: configuration properties>code generation>runtime library : multi-threaded(/Mt) Properties: configuration properties>Precompiles header:Not using precompiled headers

Debug version Properties: configuration properties>c/c++>General>Warning level>level4(/W4) Properties: configuration properties>code generation>runtime library : multi-threaded(/MTd) Properties: configuration properties>Precompiles header:Not using precompiled headers


From: http://stackoverflow.com/questions/13279015/what-libraries-do-i-need-to-link-to-build-a-googlemock-example 





1>msvcrt.lib(ti_inst.obj) : error LNK2005: "private: __cdecl type_info::type_info(class type_info const &)" (??0type_info@@AEAA@AEBV0@@Z) 已经在 LIBCMTD.lib(typinfo.obj) 中定义 1>msvcrt.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __cdecl type_info::operator=(class type_info const &)" (??4type_info@@AEAAAEAV0@AEBV0@@Z) 已经在 LIBCMTD.lib(typinfo.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: atof 已经在 LIBCMTD.lib(atof.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: sprintf_s 已经在 LIBCMTD.lib(sprintf.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: printf 已经在 LIBCMTD.lib(printf.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: free 已经在 LIBCMTD.lib(dbgfree.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: malloc 已经在 LIBCMTD.lib(dbgmalloc.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: fclose 已经在 LIBCMTD.lib(fclose.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: fputc 已经在 LIBCMTD.lib(fputc.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: fopen_s 已经在 LIBCMTD.lib(fopen.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: fgetc 已经在 LIBCMTD.lib(fgetc.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: fopen 已经在 LIBCMTD.lib(fopen.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: strstr 已经在 LIBCMTD.lib(strstr.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: strcpy_s 已经在 LIBCMTD.lib(strcpy_s.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: memcpy_s 已经在 LIBCMTD.lib(memcpy_s.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: memmove_s 已经在 LIBCMTD.lib(memmove_s.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: wcslen 已经在 LIBCMTD.lib(wcslen.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: memmove 已经在 LIBCMTD.lib(memcpy.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: vsprintf_s 已经在 LIBCMTD.lib(vsnprnc.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: "public: __cdecl std::exception::exception(char const * const &)" (??0exception@std@@QEAA@AEBQEBD@Z) 已经在 LIBCMTD.lib(stdexcpt.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: "public: virtual __cdecl std::exception::~exception(void)" (??1exception@std@@UEAA@XZ) 已经在 LIBCMTD.lib(stdexcpt.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: "public: __cdecl std::exception::exception(class std::exception const &)" (??0exception@std@@QEAA@AEBV01@@Z) 已经在 LIBCMTD.lib(stdexcpt.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: _stricmp 已经在 LIBCMTD.lib(stricmp.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: getc 已经在 LIBCMTD.lib(fgetc.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: system 已经在 LIBCMTD.lib(system.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: getenv_s 已经在 LIBCMTD.lib(getenv.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: atoi 已经在 LIBCMTD.lib(atox.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: fwrite 已经在 LIBCMTD.lib(fwrite.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: ftell 已经在 LIBCMTD.lib(ftell.obj) 中定义 1>msvcrt.lib(MSVCR100.dll) : error LNK2005: fseek 已经在 LIBCMTD.lib(fseek.obj) 中定义 1>msvcprt.lib(MSVCP100.dll) : error LNK2005: "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPEBD@Z) 已经在 libcpmtd.lib(xthrow.obj) 中定义 1>msvcprt.lib(MSVCP100.dll) : error LNK2005: "void __cdecl std::_Xout_of_range(char const *)" (?_Xout_of_range@std@@YAXPEBD@Z) 已经在 libcpmtd.lib(xthrow.obj) 中定义 1> 正在创建库 E:\Code\Work\diaoSlide\04-diaoSlide-HuaKuaiZuo\x64\Debug\/diaoSlide.lib 和对象 E:\Code\Work\diaoSlide\04-diaoSlide-HuaKuaiZuo\x64\Debug\/diaoSlide.exp 1>LIBCMTD.lib(crt0init.obj) : warning LNK4098: 默认库“msvcrt.lib”与其他库的使用冲突;请使用 /NODEFAULTLIB:library 1>E:\Code\Work\diaoSlide\04-diaoSlide-HuaKuaiZuo\x64\Debug\diaoSlide.dll : fatal error LNK1169: 找到一个或多个多重定义的符号 1>已完成生成项目“GuideRail.vcxproj”的操作 - 失败。
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值