执行编译命令:
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-mt