weixin_41318405 2019-06-28 15:22 采纳率: 50%
浏览 595

ubuntu中编译boost::asio出现下面错误

#include <boost/asio.hpp>
#include <iostream>

void handler(const boost::system::error_code &ec) {
    std::cout << "5 s." << std::endl;
}

int main() {
    boost::asio::io_service io_service;
    boost::asio::deadline_timer timer(io_service,
                      boost::posix_time::seconds(5));
    timer.async_wait(handler);
    io_service.run();
    return 0;
}

g++ timer.cc

/tmp/cc6rBUr7.o:在函数‘__static_initialization_and_destruction_0(int, int)’中:

timer.cc:(.text+0x12f):对‘boost::system::generic_category()’未定义的引用

timer.cc:(.text+0x13b):对‘boost::system::generic_category()’未定义的引用

timer.cc:(.text+0x147):对‘boost::system::system_category()’未定义的引用

/tmp/cc6rBUr7.o:在函数‘boost::system::error_code::error_code()’中:
timer.cc:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17):对‘boost::system::system_category()’未定义的引用

/tmp/cc6rBUr7.o:在函数‘boost::system::error_category::std_category::equivalent(int, std::error_condition const&) const’中:
timer.cc:(.text._ZNK5boost6system14error_category12std_category10equivalentEiRKSt15error_condition[_ZNK5boost6system14error_category12std_category10equivalentEiRKSt15error_condition]+0xb8):对‘boost::system::generic_category()’未定义的引用

timer.cc:(.text._ZNK5boost6system14error_category12std_category10equivalentEiRKSt15error_condition[_ZNK5boost6system14error_category12std_category10equivalentEiRKSt15error_condition]+0xf3):对‘boost::system::generic_category()’未定义的引用

/tmp/cc6rBUr7.o:在函数‘boost::system::error_category::std_category::equivalent(std::error_code const&, int) const’中:
timer.cc:(.text._ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei[_ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei]+0xb8):对‘boost::system::generic_category()’未定义的引用

timer.cc:(.text._ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei[_ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei]+0xf3):对‘boost::system::generic_category()’未定义的引用

timer.cc:(.text._ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei[_ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei]+0x1d2):对‘boost::system::generic_category()’未定义的引用

/tmp/cc6rBUr7.o:在函数‘boost::asio::error::get_system_category()’中:
timer.cc:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4asio5error19get_system_categoryEv]+0x5):对‘boost::system::system_category()’未定义的引用

collect2: error: ld returned 1 exit status

  • 写回答

1条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2022-09-20 21:26
    关注
    不知道你这个问题是否已经解决, 如果还没有解决的话:

    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^
    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥50 基于极化码的电力线通信系统仿真