我在 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) ===|
最佳答案
您需要链接到 libboost_system
,例如c++ you-file.cxx -lboost_system
关于c++ - boost asio 示例测试失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20597018/