2010-11-23 197 views
2

所以,我試圖使用boost.process庫。我下載的程序包從this location,複製包括從升壓子目錄到/usr/include目錄/升壓,寫了一個簡單的代碼:Boost鏈接錯誤

namespace bp = ::boost::process; 
    std::string execApp = "make"; 
    std::vector<std::string> args; 
    args.push_back("-C ../build"); 

    bp::context ctx; 
    ctx.stdout_behavior = bp::silence_stream(); 

    bp::child buildProcess = bp::launch(execApp, args, ctx); 

它編譯,但在連接失敗:

CMakeFiles/DebugConsole.dir/Debug/DebugConsole.cpp.o: In function `__static_initialization_and_destruction_0': 
/usr/include/boost/system/error_code.hpp:208: undefined reference to `boost::system::get_system_category()' 
/usr/include/boost/system/error_code.hpp:209: undefined reference to `boost::system::get_generic_category()' 
/usr/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::get_generic_category()' 
/usr/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::get_generic_category()' 
/usr/include/boost/system/error_code.hpp:216: undefined reference to `boost::system::get_system_category()' 
CMakeFiles/DebugConsole.dir/Debug/DebugConsole.cpp.o: In function `boost::process::detail::file_handle::posix_remap(int)': 
/usr/include/boost/process/detail/file_handle.hpp:264: undefined reference to `boost::system::get_system_category()' 
/usr/include/boost/process/detail/file_handle.hpp:269: undefined reference to `boost::system::get_system_category()' 
CMakeFiles/DebugConsole.dir/Debug/DebugConsole.cpp.o: In function `boost::process::detail::file_handle::posix_dup(int, int)': 
/usr/include/boost/process/detail/file_handle.hpp:295: undefined reference to `boost::system::get_system_category()' 
CMakeFiles/DebugConsole.dir/Debug/DebugConsole.cpp.o: In function `pipe': 
/usr/include/boost/process/detail/pipe.hpp:86: undefined reference to `boost::system::get_system_category()' 
CMakeFiles/DebugConsole.dir/Debug/DebugConsole.cpp.o:/usr/include/boost/process/detail/posix_ops.hpp:202: more undefined references to `boost::system::get_system_category()' follow 
collect2: ld returned 1 exit status 

我已經這樣的鏈接庫:filesystem system date_time

+0

發表您的鏈接線 – 2010-11-23 19:02:28

回答

4

您可能希望看到最後的答案here.

我有一個非常類似的問題,並發現這個職位,而搜索。我在 設法解決了更多搜索後的問題,所以我發佈 在這裏爲其他人。

我不得不這樣鏈接到正確的庫:G ++ boost_example.cpp -o 運行-lboost_filesystem-MT http://linux.overshoot.tv/ticket/127

真正的問題是,提升文檔缺乏,不 不能說哪個庫鏈接到。請參閱: http://linux.overshoot.tv/ticket/129

無論如何,要使用boost/file_system,請鏈接到:-lboost_filesystem-mt。

參見:http://ubuntuforums.org/showthread.php?t=244593