【编译错误】xxxx.cpp:(.text+0x190): undefined reference to `std::ios_base::Init::Init()‘

前提:我的代码文件是cpp。

原始输入:

gcc modbus_TCP_test.cpp -L/home/xxx/libmodbus/install/lib -lmodbus

报错信息:

/tmp/ccy4FgrD.o: In function `__static_initialization_and_destruction_0(int, int)':
modbus_TCP_test.cpp:(.text+0x190): undefined reference to `std::ios_base::Init::Init()'
modbus_TCP_test.cpp:(.text+0x1a4): undefined reference to `std::ios_base::Init::~Init()'
modbus_TCP_test.cpp:(.text+0x1a8): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status

正确输入:

g++ modbus_TCP_test.cpp -L/home/zbr/zbr/libmodbus/install/lib -lmodbus

gcc 改成 g++就不报错了。

参考资料:
在这里插入图片描述
https://stackoverflow.com/questions/10906275/undefined-reference-to-stdios-baseinitinit

在这里插入图片描述
Linux环境C++编译报错:undefined reference to `std::ios_base::Init::Init()

此方法只是恰好解决了我的问题,具体原因我也不懂,如果有存在什么错误,或恰好您知道原因,欢迎在评论区留言,感激不尽!!!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值