我正在尝试编译阻塞 TCP 回显客户端的示例:使用 Boost.build b2 命令,如下所示:
b2 linkflags=-lpthread toolset=gcc threading=multi link=static
但我收到以下错误:
gcc.link ../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/lte_sim
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `boost::asio::detail::socket_ops::getaddrinfo(char const*, char const*, addrinfo const&, addrinfo**, boost::system::error_code&)':
/home/ha/MIH/boost_1_49_0/boost/asio/detail/impl/socket_ops.ipp:2899: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `__static_initialization_and_destruction_0(int, int)':
Simulator_main.cpp:(.text+0x68f): undefined reference to `boost::system::generic_category()'
Simulator_main.cpp:(.text+0x69b): undefined reference to `boost::system::generic_category()'
Simulator_main.cpp:(.text+0x6a7): undefined reference to `boost::system::system_category()'
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `boost::system::error_code::error_code()':
Simulator_main.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17): undefined reference to `boost::system::system_category()'
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `boost::asio::error::get_system_category()':
Simulator_main.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[boost::asio::error::get_system_category()]+0x5): undefined reference to `boost::system::system_category()'
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `void boost::asio::detail::posix_event::clear<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)':
Simulator_main.cpp:(.text._ZN5boost4asio6detail11posix_event5clearINS1_11scoped_lockINS1_11posix_mutexEEEEEvRT_[void boost::asio::detail::posix_event::clear<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)]+0x47): undefined reference to `odtone::crash(odtone::bug, char const*, char const*, unsigned int, char const*)'
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `void boost::asio::detail::posix_event::wait<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)':
Simulator_main.cpp:(.text._ZN5boost4asio6detail11posix_event4waitINS1_11scoped_lockINS1_11posix_mutexEEEEEvRT_[void boost::asio::detail::posix_event::wait<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)]+0x47): undefined reference to `odtone::crash(odtone::bug, char const*, char const*, unsigned int, char const*)'
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `void boost::asio::detail::posix_event::signal<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)':
Simulator_main.cpp:(.text._ZN5boost4asio6detail11posix_event6signalINS1_11scoped_lockINS1_11posix_mutexEEEEEvRT_[void boost::asio::detail::posix_event::signal<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)]+0x47): undefined reference to `odtone::crash(odtone::bug, char const*, char const*, unsigned int, char const*)'
../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o: In function `void boost::asio::detail::posix_event::signal_and_unlock<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)':
Simulator_main.cpp:(.text._ZN5boost4asio6detail11posix_event17signal_and_unlockINS1_11scoped_lockINS1_11posix_mutexEEEEEvRT_[void boost::asio::detail::posix_event::signal_and_unlock<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)]+0x47): undefined reference to `odtone::crash(odtone::bug, char const*, char const*, unsigned int, char const*)'
collect2: ld returned 1 exit status
"g++" -o "../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/lte_sim" -Wl,--start-group "../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/Simulator_main.o" "/home/ha/MIH/boost_1_49_0/bin.v2/libs/program_options/build/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/libboost_program_options.a" -lrt -Wl,--end-group -g -static -pthread -lpthread
...failed gcc.link ../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi/lte_sim...
...skipped <p../../dist>lte_sim for lack of <p../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/threading-multi>lte_sim...
...failed updating 1 target...
...skipped 1 target..
我已经有一个包含以下内容的 JamFile:
install install
: lte_sim
: <location>../../dist
;
project lte_sim
;
exe lte_sim
: Simulator_main.cpp
/boost//program_options
;
那么问题的解决方案是什么?
非常感谢。
我尝试了“b2 linkflags=-lboost_system toolset=gcc”,但出现以下错误
gcc.link ../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/lte_sim /usr/bin/ld:找不到-lboost_system ../.. /bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/Simulator_main.o:在函数`boost::asio::detail::socket_ops::getaddrinfo(char const*, char const*, addrinfo const&, addrinfo**, boost::system::error_code&)': /home/ha/MIH/boost_1_49_0/boost/asio/detail/impl/socket_ops.ipp:2899: 警告:使用'getaddrinfo'在静态链接的应用程序中,在运行时需要来自 glibc 版本的共享库,用于链接 collect2:ld 返回 1 退出状态
"g++" -o "../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/lte_sim" -Wl,--start-group "../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/Simulator_main.o" "/home/ha/MIH/boost_1_49_0/bin.v2/libs/program_options/build/gcc-4.6/debug/link-static/runtime-link-static/libboost_program_options.a" -Wl,--end-group -g -static -lboost_system
...失败 gcc.link ../../bin.v2/app/lte_sim/gcc-4.6/debug/link-static/runtime-link-static/lte_sim ... ...由于缺少 lte_sim 而跳过 lte_sim ... ...更新 1 个目标失败... ...跳过 1 个目标...
那么有什么建议吗?