试图获取Boost库的设置并编译/运行一些Boost教程,但遇到了问题。我已经在Google周围搜索并尝试了一些方法,但是似乎没有任何效果。如果你们能为我指出正确的方向,将不胜感激。
这是命令行的输出:
g ++ -I / usr / local / boost_1_68_0 / timer.cpp -o计时器 /tmp/ccLjn1qn.o:在函数
boost::system::system_category()': timer.cpp:(.text._ZN5boost6system15system_categoryEv[_ZN5boost6system15system_categoryEv]+0x7): undefined reference to
boost :: system :: detail :: system_category_instance'中 /tmp/ccLjn1qn.o:在函数boost::system::generic_category()': timer.cpp:(.text._ZN5boost6system16generic_categoryEv[_ZN5boost6system16generic_categoryEv]+0x7): undefined reference to
中的boost :: system :: detail :: generic_category_instance' /tmp/ccLjn1qn.o:在函数boost::asio::detail::posix_event::posix_event()': timer.cpp:(.text._ZN5boost4asio6detail11posix_eventC2Ev[_ZN5boost4asio6detail11posix_eventC5Ev]+0x4d): undefined reference to
pthread_condattr_setclock'中 /tmp/ccLjn1qn.o:在函数boost::asio::detail::posix_thread::~posix_thread()': timer.cpp:(.text._ZN5boost4asio6detail12posix_threadD2Ev[_ZN5boost4asio6detail12posix_threadD5Ev]+0x26): undefined reference to
pthread_detach'中 /tmp/ccLjn1qn.o:在函数boost::asio::detail::posix_thread::join()': timer.cpp:(.text._ZN5boost4asio6detail12posix_thread4joinEv[_ZN5boost4asio6detail12posix_thread4joinEv]+0x2b): undefined reference to
pthread_join'中 /tmp/ccLjn1qn.o:在函数boost::asio::basic_waitable_timer<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock> >::basic_waitable_timer(boost::asio::io_context&, std::chrono::duration<long, std::ratio<1l, 1000000000l> > const&)': timer.cpp:(.text._ZN5boost4asio20basic_waitable_timerINSt6chrono3_V212steady_clockENS0_11wait_traitsIS4_EEEC2ERNS0_10io_contextERKNS2_8durationIlSt5ratioILl1ELl1000000000EEEE[_ZN5boost4asio20basic_waitable_timerINSt6chrono3_V212steady_clockENS0_11wait_traitsIS4_EEEC5ERNS0_10io_contextERKNS2_8durationIlSt5ratioILl1ELl1000000000EEEE]+0x41): undefined reference to
boost :: system :: detail :: system_category_instance'中 /tmp/ccLjn1qn.o:在函数boost::asio::basic_waitable_timer<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock> >::wait()': timer.cpp:(.text._ZN5boost4asio20basic_waitable_timerINSt6chrono3_V212steady_clockENS0_11wait_traitsIS4_EEE4waitEv[_ZN5boost4asio20basic_waitable_timerINSt6chrono3_V212steady_clockENS0_11wait_traitsIS4_EEE4waitEv]+0x26): undefined reference to
boost :: system :: detail :: system_category_instance'中 /tmp/ccLjn1qn.o:在函数boost::asio::detail::deadline_timer_service<boost::asio::detail::chrono_time_traits<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock> > >::destroy(boost::asio::detail::deadline_timer_service<boost::asio::detail::chrono_time_traits<std::chrono::_V2::steady_clock, boost::asio::wait_traits<std::chrono::_V2::steady_clock> > >::implementation_type&)': timer.cpp:(.text._ZN5boost4asio6detail22deadline_timer_serviceINS1_18chrono_time_traitsINSt6chrono3_V212steady_clockENS0_11wait_traitsIS6_EEEEE7destroyERNSA_19implementation_typeE[_ZN5boost4asio6detail22deadline_timer_serviceINS1_18chrono_time_traitsINSt6chrono3_V212steady_clockENS0_11wait_traitsIS6_EEEEE7destroyERNSA_19implementation_typeE]+0x29): undefined reference to
boost :: system :: detail :: system_category_instance'中 collect2:错误:ld返回1退出状态
答案 0 :(得分:0)
您需要了解有关链接库的信息(例如-l boost_system -l boost_thread -l boost_asio
)。 Boost文档应具有usage examples.