【问题标题】:boost asio example test failsboost asio 示例测试失败
【发布时间】:2014-01-07 03:24:37
【问题描述】:

我在 fedora xfce 上运行了一个简单的 boost asio 示例……它给出了这些错误……知道吗?

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

int main( int argc, char * argv[] )
{
    boost::asio::io_service io_service;

    io_service.run();

    std::cout << "Do you reckon this line displays?" << std::endl;

    return 0;
}

输出:

obj/Debug/main.o||In function `__static_initialization_and_destruction_0':|
/usr/include/boost/system/error_code.hpp|214|undefined reference to `boost::system::generic_category()'|
/usr/include/boost/system/error_code.hpp|215|undefined reference to `boost::system::generic_category()'|
/usr/include/boost/system/error_code.hpp|216|undefined reference to `boost::system::system_category()'|
obj/Debug/main.o||In function `boost::system::error_code::error_code()':|
/usr/include/boost/system/error_code.hpp|315|undefined reference to `boost::system::system_category()'|
obj/Debug/main.o||In function `boost::asio::error::get_system_category()':|
/usr/include/boost/asio/error.hpp|216|undefined reference to `boost::system::system_category()'|
||=== Build finished: 5 errors, 0 warnings (0 minutes, 1 seconds) ===|

【问题讨论】:

  • 无论如何,我使用 Boost 1.49 在 Windows 8 下按原样编译并链接了您的测试程序,没有编译错误。所以至少你知道你的程序没有任何有机错误。

标签: c++ boost boost-asio


【解决方案1】:

您需要链接到libboost_system,例如c++ you-file.cxx -lboost_system

【讨论】:

猜你喜欢
  • 2013-08-30
  • 2017-08-22
  • 1970-01-01
  • 2018-12-03
  • 1970-01-01
  • 1970-01-01
  • 2023-01-26
  • 2012-10-26
  • 2016-12-23
相关资源
最近更新 更多