您的位置:首页 > 其它

解决Link 2001错误的一种方法

2016-03-17 10:29 330 查看
首先感谢:http://www.cppblog.com/kenlistian/archive/2008/11/14/66872.html
我想将PhysX SDK中的一个Sample(SampleRayCar) 独立出来。
我把所有原例子中的cpp和h文件都考到我新建的工程目录下之后,编译过了,但是连接出了问题,不知道怎么解决。

错误信息:

 

Car.obj : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "public: bool __thiscall std::_Tree<class std::_Tmap_traits<float,float,struct std::less<float>,class std::allocator<struct std::pair<float const ,float> >,0> >::const_iterator::operator==(class std::_Tree<class std::_Tmap_traits<float,float,struct std::less<float>,class std::allocator<struct std::pair<float const ,float> >,0> >::const_iterator const &)const " (??8const_iterator@?$_Tree@V?$_Tmap_traits@MMU?$less@M@std@@V?$allocator@U?$pair@$$CBMM@std@@@2@$0A@@std@@@std@@QBE_NABV012@@Z)
1>NxAllVehicles.obj : error LNK2001: unresolved external symbol __CrtDbgReportW
1>NxVehicle.obj : error LNK2001: unresolved external symbol __CrtDbgReportW

我没注意到上面还有一个warning,如下:

LINK : warning LNK4098: 默认库“LIBCMT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library

从这个warning中推断出来,是运用了错误的运行库包。

 

在一程序中使用不同类型的运行时库或使用调试和非调试版本的运行时库,则将收到此链接错误。

例如,编译一个文件以使用一种运行时库,而编译另一个文件以使用另一种运行时库(例如单线程运行时库对多线程运行时库),试图链接它们,则

将得到此警告。应将所有源文件编译为使用同一运行时库。

其实就是调正编译器选项参数:/MD、/MT 和 /LD

在vc8中,在“配置属性-->C/C++-->代码生成-->运行时库”中将“多线程(/MT)”统一改为“多线程调试(/MTd)”即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: