vs2008至vs2012切换报链接错误

本文详细介绍了在使用不同版本的Visual Studio编译程序时遇到的链接错误问题,并提供了针对性的解决方案,包括如何调整项目属性以确保程序在不同版本的编译环境下正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

【问题描述】

vs2008下编译的程序拷贝至vs2010下编译,报如下错误:

Error 108 error LNK2019: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::assign(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned int,unsigned int)" (?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@ABV12@II@Z)*******

【原因分析】

引用的静态库jrtplib.lib的运行库与当前代码使用的运行库不同

【解决方案】

1.

http://stackoverflow.com/questions/12074439/linking-static-libs-built-with-vs2008-from-a-vs2012-project-are-they-compatible

在项目属性中设置一下属性:/NODEFAULTLIB[:library],编译通过


2.jrtplib.lib重新用vs2010重新编译,运行库选择 /MDd(debug下)

  调用该库的项目,也选择为/MDd,同时“忽略特定默认库”——>

LIBCMT
LIBCMTD
LIBC
LIBCD


另:要学会使用 vs自带工具 dumpbin。


参考

http://blog.youkuaiyun.com/pgmsoul/article/details/4203941

http://blog.youkuaiyun.com/hevc_cjl/article/details/8497268


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值