看板 Programming 關於我們 聯絡資訊
在下先說明環境: 作業系統:WinXP with SP2 編譯環境:MinGW + MSYS 再來說編譯過程: bjam --toolset=gcc --bulid-type=release --with-system --with-thread --with-date_time --with-regex --with-serialization install 最後還不放心,又在做一次: bjam --toolset=gcc --build-type=complete install 但是針對這個範例程式: #include <iostream> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time.hpp> int main() { boost::asio::io_service io; boost::asio::deadline_timer t(io, boost::posix_time::seconds(5)); t.wait(); std::cout << "Hello, world!\n"; return 0; } 編譯指令: $ g++ -I /Boost/include/boost-1_35/ -L /Boost/lib/ 01.cpp 卻出現以下錯誤訊息: C:/WINDOWS/Temp/ccomTj71.o:01.cpp:(.text+0x301): undefined reference to `boost::system::get_system_category()' C:/WINDOWS/Temp/ccomTj71.o:01.cpp:(.text+0x31a): undefined reference to `boost::system::get_posix_category()' C:/WINDOWS/Temp/ccomTj71.o:01.cpp:(.text+0x333): undefined reference to `boost::system::get_posix_category()' C:/WINDOWS/Temp/ccomTj71.o:01.cpp:(.text+0x34c): undefined reference to `boost::system::get_system_category()' C:/WINDOWS/Temp/ccomTj71.o:01.cpp:(.text$_ZN5boost4asio5error19get_system_categoryEv[boost::asio::error::get_system_category()]+0x7): undefined reference to `boost::system::get_system_category()' C:/WINDOWS/Temp/ccomTj71.o:01.cpp:(.text$_ZN5boost6system10error_codeC1Ev[boost::system::error_code::error_code()]+0x14): undefined reference to `boost::system::get_system_category()' C:/WINDOWS/Temp/ccomTj71.o:01.cpp:(.text$_ZN5boost4asio6detail12winsock_initILi2ELi0EE7do_initC1Ev[boost::asio::detail::winsock_init<2, 0>::do_init::do_init()]+0x1f): undefined reference to `WSAStartup@8' C:/WINDOWS/Temp/ccomTj71.o:01.cpp:(.text$_ZN5boost4asio6detail10socket_ops6selectEiP6fd_setS4_S4_P7timevalRNS_6system10error_codeE[boost::asio::detail::socket_ops::select(int, fd_set*, fd_set*, fd_set*, timeval*, boost::system::error_code&)]+0xe1): undefined reference to `select@20' C:/WINDOWS/Temp/ccomTj71.o:01.cpp:(.text$_ZN5boost4asio6detail10socket_ops13error_wrapperIiEET_S4_RNS_6system10error_codeE[int boost::asio::detail::socket_ops::error_wrapper<int>(int, boost::system::error_code&)]+0x13): undefined reference to `WSAGetLastError@0' C:/WINDOWS/Temp/ccomTj71.o:01.cpp:(.text$_ZN5boost4asio6detail10socket_ops11clear_errorERNS_6system10error_codeE[boost::asio::detail::socket_ops::clear_error(boost::system::error_code&)]+0xf): undefined reference to `WSASetLastError@4' C:/WINDOWS/Temp/ccomTj71.o:01.cpp:(.text$_ZN5boost4asio6detail12winsock_initILi2ELi0EE7do_initD1Ev[boost::asio::detail::winsock_init<2, 0>::do_init::~do_init()]+0x7): undefined reference to `WSACleanup@0' collect2: ld returned 1 exit status 請問,問題是出在那兒呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.100.86.180