执行编译命令:
g++ -lboost_system-mt -I/home/base/boost_1_58_0 -L/home/base/boost_1_58_0/stage/lib client.cpp -o client
出现错误提示:
/tmp/ccpebBMj.o: In function `__static_initialization_and_destruction_0(int, int)':
client.cpp:(.text+0x2f3): undefined reference to `boost::system::generic_category()'
client.cpp:(.text+0x2ff): undefined reference to `boost::system::generic_category()'
client.cpp:(.text+0x30b): undefined reference to `boost::system::system_category()'
/tmp/ccpebBMj.o: In function `boost::system::error_code::error_code()':
client.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17): undefined reference to `boost::system::system_category()'
/tmp/ccpebBMj.o: In function `boost::asio::error::get_system_category()':
client.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[boost::asio::error::get_system_category()]+0x5): undefined reference to `boost::system::system_category()'
collect2: ld returned 1 exit status
经过测试有两种解决方法:
一、使用-lboost_system库
g++ -lboost_system -I/home/base/boost_1_58_0 -L/home/base/boost_1_58_0/stage/lib client.cpp -o client
二、改变-lboost_system-mt的位置,在最后面添加一个-lboost_system-mt
g++ -lboost_system-mt -I/home/base/boost_1_58_0 -L/home/base/boost_1_58_0/stage/lib client.cpp -o client -lboost_system-