这个问题的来源是这样的,我想要静态编译发布我程序,就是Runtime Library 设置为:Multi-threaded Debug (/MTd)
程序悲剧的报错了:
Error 2 error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
Error 3 error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
一开始搜到这位可耐的网友:http://sanqiaosiyou.blog.sohu.com/161348612.html
大致是两种库一起使用的问题,解决方案很粗暴,把libcmtd 直接Ignore 掉
Project Settings: -> Configration Properties -> Linker -> Input -> Ignore Specific Library: libcmtd
然后悲剧的通篇都是外部引用错误:
error LNK2019: unresolved external symbol _ungetc referenced in function "bool __cdecl std::_Ungetc<char>(char const &,struct _iobuf *)" (??$_Ungetc@D@std@@YA_NABDPAU_iobuf@@@Z)
很明显,我要用libcmtd!!!
网友说:libcmtd 这个库有时候不能忽略,忽略后会有不能解析的外部符号错误;其实有个方便的方法 链接时加入参数 /FORCE:MULTIPLE
然后我找了N长时间居然不知道怎么在vs2010里设置链接时的参数。。。。悲剧。。。。。
这中间还有个插曲
出现错误:Error 2 error LNK1181: cannot open input file 'kernel32.lib'
对于这个问题,这位辛勤的小网友带我饶了很多路:http://blogs.msdn.com/b/saurabh_singh/archive/2009/01/30/getting-fatal-error-lnk1181-cannot-open-input-file-kernel32-lib.aspx
后来我在C盘找到这个 kernel32.lib 文件把地址添加到了Linker->Input里面,
又出现 Error 2 error LNK1181: cannot open input file '******.lib'
貌似都是SDK里的lib,后来终于发现原来我不小心改掉了 Linker->Input->Additional Dependencies 里原本默认要加载的库:
要选上这个框!
再回到原来重复定义的问题
错误的大致意思是一个东西在 里重复定义了LIBCMTD.lib,报错的是msvcrtd.lib,所以改一下两个加载的顺序应该就可以。
然后发现VS2010默认加载的库配置是不能改的。。。。。
于是用了个很笨的方法:
先在Configuration Properties->Liner->Input->Ignore Specific Default Libraries中输入:LIBCMTD.lib;msvcrtd.lib
就是把这两个冲突库Ignore掉
再在Configuration Properties->Liner->Input->Additional Dependecies中添加:msvcrtd.lib;LIBCMTD.lib
把他们按不冲突的顺序再添加进来
这种无聊的方法还是有效的解决了问题
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
哈哈~
分享到:
相关推荐
error LNK2005: DllMain already defined in corelibc.lib(dllmain.obj)的解决方案
uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj) uafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl ...
1>msvcrtd.lib(MSVCR110D.dll) : error LNK2005: _free 已经在 libcmtd.lib(dbgfree.obj) 中定义 1>msvcrtd.lib(MSVCR110D.dll) : error LNK2005: _malloc 已经在 libcmtd.lib(dbgmalloc.obj) 中定义 1>msvcrtd.lib...
2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj) nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj) Debug/DCap...
mfcs40d.lib(dllmodul.obj):error LNK2005:_DllMain@12 already defined in MSVCRTD.LIB (dllmain.obj) mfcs42d.lib(dllmodul.obj):error LNK2005:_DllMain@12 already defined in msvcrtd.lib(dllmain.obj)
完美解决VS2003.Net fatal error LNK1201: 写入程序数据库“.pdb”时出错 文末给出一个完美的解决方案和一个懒人补丁包。问题描述如下:在重新编译的时候,经常报错: fatal error LNK1201: 写入程序数据库“.pdb”...
LNK2005:symbol already defined和LNK1169:one or more multiply defined symbols found
怎么VC6编译工程的时候老是提示: LINK : fatal error LNK1104: cannot open file "uafxcwd.lib" 用这个库就好了!!!
uafxcwd.lib多见于VC6编译过程中,有时候会遇到“ fatal error LNK1104: cannot open file "uafxcwd.lib"”,意思是找不到uafxcwd.lib库文件,你可在此下载,存放在提示的路径下即可,若缺少这个文件而不修复的话,...
在使用不同版本opencv时,编译器有时会报错,error LNK1104 无法打开文件opencv_core245d.lib,本文给出了详细的解决方法,实测有效
vs2010或vs2015等项目编译不通过,提示:1>odbccp32.lib(dllload.obj) : error LNK2019: 无法解析的外部符号 __vsnwprintf_s,该符号在函数 _StringCchPrintfW 中被引用 1>XuglassForm.exe : fatal error LNK1120: 1...
本篇文章是对fatal error LNK1104: 无法打开文件“libc.lib”的解决方法进行了详细的分析介绍,需要的朋友参考下
VS报错:fatal error LNK1104: 无法打开文件“ucrtd.lib”解决办法,将文件复制后粘贴在相应位置,便可解决问题。具体方法见以下链接:https://blog.csdn.net/qq_43297971/article/details/121170313
解决error LNK2001: unresolved external symbol
libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16 msvcrtd.lib(crtexew.obj) : error LNK2001: ...
解决安装vs2012后vs2010 LINK : fatal error LNK1123: failure during conversion to COFF Wrong version: 03/18/2010 01:16 PM 31,048 cvtres.exe Correct version: 02/21/2011 06:03 PM 31,056 cvtres.exe
(2)error LNK2005: _main already defined in xxxx.obj 编号:LNK2005 直译:_main已经存在于xxxx.obj中了。 错误分析: 直接的原因是该程序中有多个(不止一个)main函数。这是初学C++的低年级同学在初次编程时经常...
LINK : fatal error LNK1104: cannot open file "libcpd.lib" 这是因为编译器在默认的库文件目录里找不到这个库文件,把这个文件解压缩出来,然后将它拷贝到你的库文件存放的地方,比如E:\Microsoft Visual Studio\...
LINK : fatal error LNK1104: cannot open file "mfc42u.lib"-附件资源