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
    关注
    不知道你这个问题是否已经解决, 如果还没有解决的话:

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

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog