VC 链接时new和delete运算符已经在 LIBCMTD.lib 中定义解决方法

error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) 已经在 LIBCMTD.lib(new.obj) 中定义

error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) 已经在 LIBCMTD.lib(dbgdel.obj) 中定义

error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) 已经在 LIBCMTD.lib(new2.obj) 中定义
error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) 已经在 LIBCMTD.lib(delete2.obj) 中定义
上网搜了下,是CRT库与MFC库的冲突,解决方法是:让程序先链接Nafxcwd.lib,然后再链接Libcmtd.lib


you've got to change the order inwhich the libraries are linked. This is a bit tricky, since the library are linked automatically, without you explicitly specifying them.

So, first step, tell the linker to ignore the implicit libraries: Project/Setting/Linker, Input Tab, and put "Nafxcwd.lib Libcmtd.lib" in the "Libraries to Ignore" box.

Next, on the same page, in the Object/library Modules box, put the same to libraries. (in you still get the same error, try reversing them on this line)
--

中文

项目--属性 ---连接器---输入  

                              附加依赖项    空格Nafxcwd.lib Libcmtd.lib

                              忽略指定库    空格Nafxcwd.lib Libcmtd.lib

清除项目。重新编译。搞定



文章来源:http://www.cnblogs.com/xianqingzh/archive/2009/10/29/1591868.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值