collect2: error: ld returned 1 exit status,[abi:cxx11]'被多次定义

博客介绍了Ubuntu和Windows 10系统下使用CMake编译项目时出现重定义错误的情况。在封装项目为库,采用hpp/cpp格式时,编译正常但连接报错。经检查发现是xxx.hpp内使用全局函数和变量,xxx.cpp直接调用所致,修正方法是将其移到xxx.cpp内。

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

ubuntu使用cmake报错形式:

CMakeFiles/finder.dir/finder_udp.cpp.o:(.bss+0x0): `m_[abi:cxx11]'被多次定义
CMakeFiles/finder.dir/finder.cpp.o:(.bss+0x0):第一次在此定义
collect2: error: ld returned 1 exit status
CMakeFiles/finder.dir/build.make:276: recipe for target 'finder' failed
make[2]: *** [finder] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/finder.dir/all' failed
make[1]: *** [CMakeFiles/finder.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Windows10使用cmake报错形式:

finder_udp.obj : error LNK2005: "class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class DevInfo,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_trai

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

weixin_41318405

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值