使用VC ++链接库时出现错误LNK2005

时间:2018-09-11 13:37:59

标签: visual-c++

我遇到一个非常困惑的错误。

1>Base_d.lib(Base_d.dll) : error LNK2005: "public: __cdecl std::vector<int,class std::allocator<int> >::vector<int,class std::allocator<int> >(class std::vector<int,class std::allocator<int> > const &)" (??0?$vector@HV?$allocator@H@std@@@std@@QEAA@AEBV01@@Z) already been defined in  ParametersManager.obj 
1>Base_d.lib(Base_d.dll) : error LNK2005: "public: __cdecl std::vector<int,class std::allocator<int> >::~vector<int,class std::allocator<int> >(void)" (??1?$vector@HV?$allocator@H@std@@@std@@QEAA@XZ)  already been defined in  ParametersManager.obj

库“ Base_d.lib”是基本的组件库。 我正在编写另一个链接到“ Base_d.lib”的库,新库包含“ ParametersManager”类。班级

  

“ ParametersManager”具有成员“ std :: vector _mem”

我在使用Visual Studio 2015的Windows 10上构建了该项目,尝试了许多方法并进行了多次重建,然后我发现

  

(1)如果我注释了“ _mem”,则错误消失了。

     

(2)如果我将“ std :: vector _mem”更改为“ std :: vector _mem”或任何其他类型,则错误将消失

     

(3)使用linux构建,错误消失了(但是这项工作必须在Windows上使用)

我遭受了好几天折磨,有人可以帮助我吗?

0 个答案:

没有答案
相关问题