vs报错 已经在 helpers.obj 中定义

本文详细解析了在编译过程中遇到的LNK2005错误,特别是当同一函数在多个对象文件中被重复定义时的情况。通过一个具体的例子,即std::vector类型函数的重复定义问题,阐述了解决此类链接错误的方法。

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

 已经在 helpers.obj 中定义

1>正在生成代码...
1>localizer.obj : error LNK2005: "class std::vector<class std::vector<float,class std::allocator<float> >,class std::allocator<class std::vector<float,class std::allocator<float> > > > __cdecl normalize(class std::vector<class std::vector<float,class std::allocator<float> >,class std::allocator<class std::vector<float,class std::allocator<float> > > >)" (?normalize@@YA?AV?$vector@V?$vector@MV?$allocator@M@std@@@std@@V?$allocator@V?$vector@MV?$allocator@M@std@@@std@@@2@@std@@V12@@Z) 已经在 helpers.obj 中定义
1>localizer.obj : error LNK2005: "class std::vector<class std::vector<float,class std::allocator<float> >,class std::allocator<class std::vector<float,class std::allocator<float> > > > __cdecl blur(class std::vector<class std::vector<float,class std::allocator<float> >,class std::allocator<class std::vector<float,class std::allocator<float> > > >,float)" (?blur@@YA?AV?$vector@V?$vector@MV?$allocator@M@std@@@std@@V?$allocator@V?$vector@MV?$allocator@M@std@@@std@@@2@@std@@V12@M@Z) 已经在 helpers.obj 中定义
1>localizer.obj : error LNK2005: "bool __cdecl close_enough(class std::vector<class std::vector<float,class std::allocator<float> >,class std::allocator<class std::vector<float,class std::allocator<float> > > >,class std::vector<class std::vector<float,class std::allocator<float> >,class std::allocator<class std::vector<float,class std::allocator<float> > > >)" (?close_enough@@YA_NV?$vector@V?$vector@MV?$allocator@M@std@@@std@@V?$allocator@V?$vector@MV?$allocator@M@std@@@std@@@2@@std@@0@Z) 已经在 helpers.obj 中定义
1>localizer.obj : error LNK2005: "bool __cdecl close_enough(float,float)" (?close_enough@@YA_NMM@Z) 已经在 helpers.obj 中定义

参考

error:LNK2005 已经在*.obj中定义的一种情况及解决办法

https://blog.youkuaiyun.com/zhaoyong26/article/details/84635383

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值