码迷,mamicode.com
首页 > 其他好文 > 详细

error LNK2005 : already defined in libcmt.lib

时间:2014-06-07 14:42:14      阅读:947      评论:0      收藏:0      [点我收藏+]

标签:c++   mfc   库冲突   cpp   多线程   

1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: virtual char const * __thiscall std::exception::what(void)const " (?what@exception@std@@UBEPBDXZ) already defined in libcmt.lib(stdexcpt.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined in libcmt.lib(stdexcpt.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z) already defined in libcmt.lib(stdexcpt.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z) already defined in libcmt.lib(stdexcpt.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _memmove already defined in libcmt.lib(memmove.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: __thiscall std::exception::exception(void)" (??0exception@std@@QAE@XZ) already defined in libcmt.lib(stdexcpt.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _free already defined in libcmt.lib(free.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: __thiscall std::exception::exception(char const * const &,int)" (??0exception@std@@QAE@ABQBDH@Z) already defined in libcmt.lib(stdexcpt.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __endthreadex already defined in libcmt.lib(threadex.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __beginthreadex already defined in libcmt.lib(threadex.obj)
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in libcmt.lib(typinfo.obj)
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in libcmt.lib(typinfo.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __strdup already defined in libcmt.lib(strdup.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: char const * __thiscall type_info::_name_internal_method(struct __type_info_node *)const " (?_name_internal_method@type_info@@QBEPBDPAU__type_info_node@@@Z) already defined in libcmt.lib(typinfo.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _malloc already defined in libcmt.lib(malloc.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _atoi already defined in libcmt.lib(atox.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _isdigit already defined in libcmt.lib(_ctype.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strspn already defined in libcmt.lib(strspn.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strchr already defined in libcmt.lib(strchr.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strtol already defined in libcmt.lib(strtol.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _isalpha already defined in libcmt.lib(_ctype.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strncmp already defined in libcmt.lib(strncmp.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _islower already defined in libcmt.lib(_ctype.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _isspace already defined in libcmt.lib(_ctype.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _getenv already defined in libcmt.lib(getenv.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __strtoi64 already defined in libcmt.lib(strtoq.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __errno already defined in libcmt.lib(dosmap.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: ___doserrno already defined in libcmt.lib(dosmap.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _sprintf already defined in libcmt.lib(sprintf.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _realloc already defined in libcmt.lib(realloc.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strrchr already defined in libcmt.lib(strrchr.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __close already defined in libcmt.lib(close.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __get_osfhandle already defined in libcmt.lib(osfinfo.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __setmode already defined in libcmt.lib(setmode.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __open_osfhandle already defined in libcmt.lib(osfinfo.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __commit already defined in libcmt.lib(commit.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __isatty already defined in libcmt.lib(isatty.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _fflush already defined in libcmt.lib(fflush.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: ___iob_func already defined in libcmt.lib(_file.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _toupper already defined in libcmt.lib(toupper.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __stricmp already defined in libcmt.lib(stricmp.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __strnicmp already defined in libcmt.lib(strnicmp.obj)
1>LINK : warning LNK4098: defaultlib ‘MSVCRT‘ conflicts with use of other libs; use /NODEFAULTLIB:library

1>.\Release/ManagerAPISample.exe : fatal error LNK1169: one or more multiply defined symbols found


上述错误主要是因为C Run time 函数库和MFC库存在冲突照成的.

如果我们项目中引用不同的C函数库. 微软针对C有两种C函数库.一种是普通的函数库:LIBC.LIB.格式/.特点是不支持多线程.另外一种是支持多线程的MSVCRT.lib.如果在一个工程中混合使用这两种函数库.则很容易导致LNK2005错误.一般情况下不推荐混合使用.如果真的有实际需求.最好处理方式采用MFC先C run time函数库link链接.因此推荐使用支持多线程的msvcrt.lib.

bubuko.com,布布扣

解决方法:

      改成动态库调用MFC的库文件就行了,C/C++->Code Generation->Multithread DLL (即实现/MD选项).

     别忘了设置使用动态MFC库


error LNK2005 : already defined in libcmt.lib,布布扣,bubuko.com

error LNK2005 : already defined in libcmt.lib

标签:c++   mfc   库冲突   cpp   多线程   

原文地址:http://blog.csdn.net/ctxbloger/article/details/28601693

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!