2013-12-15 97 views
0

我正在運行一個簡單的例子,在fedora xfce上進行boost asio,並且它給出了這些錯誤...任何想法?提升asio示例測試失敗

#include <boost/asio.hpp> 
#include <iostream> 

int main(int argc, char * argv[]) 
{ 
    boost::asio::io_service io_service; 

    io_service.run(); 

    std::cout << "Do you reckon this line displays?" << std::endl; 

    return 0; 
} 

輸出:

obj/Debug/main.o||In function `__static_initialization_and_destruction_0':| 
/usr/include/boost/system/error_code.hpp|214|undefined reference to `boost::system::generic_category()'| 
/usr/include/boost/system/error_code.hpp|215|undefined reference to `boost::system::generic_category()'| 
/usr/include/boost/system/error_code.hpp|216|undefined reference to `boost::system::system_category()'| 
obj/Debug/main.o||In function `boost::system::error_code::error_code()':| 
/usr/include/boost/system/error_code.hpp|315|undefined reference to `boost::system::system_category()'| 
obj/Debug/main.o||In function `boost::asio::error::get_system_category()':| 
/usr/include/boost/asio/error.hpp|216|undefined reference to `boost::system::system_category()'| 
||=== Build finished: 5 errors, 0 warnings (0 minutes, 1 seconds) ===| 
+0

對於它的價值,我使用Boost 1.49在Windows 8下編譯和鏈接測試程序,沒有編譯錯誤。所以至少你知道你的程序沒有什麼有機錯誤。 –

回答

3

您需要鏈接到libboost_system,例如c++ you-file.cxx -lboost_system

+0

我正在使用codeblock IDE ...我應該在哪裏設置? – krisdigitx

+0

檢查codeblocks文檔http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F – chill

+0

謝謝解決這個.. :) – krisdigitx