VS2003升级到VS2005的error LNK2005

序:项目中遇到的一个问题,工程从VS2003平台升级到VS2005平台。以前一切正常的工程在VS2005下面出现了大量的error LNK2005,下面讲述解决办法。

LIBCMT.lib(calloc.obj) : error LNK2005: _calloc already defined in winalloc.obj
LIBCMT.lib(realloc.obj) : error LNK2005: _realloc already defined in winalloc.obj

第一感觉是库出现了冲突,在把编译选项的MFC项由static改成shared后error全部消失,但是由于工程原因,这种改法存在隐患,在linker的commond line里面加入 /FORCE:MULTIPLE,问题解决了,但是留下一大堆的link warning,对于我这种严谨的人来说,warning也是要解决的,继续研究。

于是寻找新的解决方法,Google,呵呵,在MSDN的论坛上发现有人有和我一样的问题。

发个链接给大家。http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=133141&SiteID=1

把最重要的官方发言发贴一下。

OK,确定是微软的问题。我走上了一条正确的道路。warning没有问题。只有等微软发补丁了。

 

Hi Bill:

Well, this one sure turned into a lot of fun, and you get the bug finder's award for today...

The multiply defined symbols problem is caused by a bug in our implementation of calloc and realloc.  This bug has been brought to the attention of our devs and hopefully can be addressed in an upcoming service pack.

Since we get lucky using the /FORCE:MULTIPLE linker switch (that is - it picks up the winalloc.obj versions first and ignores the libcmt.lib versions), that is probably your best workaround for now.  I want to stress that this is a workaround and using the /FORCE linker switch should never be necessary or a common practice.  If this unblocks you, that is your workaround for the time being.  If the exe you generate with this switch has other problems, please post that fact up here - there may be another workaround, but it is complicated and risky.

Best Regards,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值