cpp中奇怪的链接错误

Strange linker error in cpp

本文关键字:链接 错误 cpp      更新时间:2023-10-16

当我将以下行添加到我的代码中时:

std::string sFrameTag

我得到以下链接错误:

Error   34  error LNK2005: "public: __thiscall std::basic_string<char,struct 
std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct 
std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?
$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in 
VFPAnalyzerApi.lib(VFPEvaluation.obj)   msvcprtd.lib

我确信sFrameTag只定义一次,我尝试使用这个变量的其他名称来确定。我有以下包括:stdio.h, time.h, string

谁能告诉我是什么原因导致这个错误?

当我试图静态地包含所有需要的运行时库时,我也得到了类似的错误。请检查当您试图导入与/MD选项静态链接的库时,您还需要使用/MD。

谢谢Niraj Rathi