2012-09-18 38 views
1

我試圖從boost :: filesystem編譯this教程文件。編譯boost文件系統的教程文件時出現問題

我使用這個命令:

clang++ -std=c++11 -stdlib=libc++ tut3.cpp -L/usr/local/lib -lboost_filesystem-mt -lboost_system-mt 

但是,我越來越:

Undefined symbols for architecture x86_64: 
    "boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::codecvt<wchar_t, char, __mbstate_t> const&)", referenced from: 
     boost::filesystem::path::path<boost::filesystem::directory_entry>(boost::filesystem::directory_entry const&, boost::enable_if<boost::filesystem::path_traits::is_pathable<boost::decay<boost::filesystem::directory_entry>::type>, void>::type*) in tut3-FljaLL.o 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

我使用包含在山獅鐺,並提升安裝有brew install --with-mpi --use-clang。 (mpich2也與--use-clang一起安裝)。

的詳細連接器輸出:

Apple clang version 4.0 (tags/Apple/clang-421.0.57) (based on LLVM 3.1svn) 
Target: x86_64-apple-darwin12.1.0 
Thread model: posix 
"/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name tut3.cpp -pic-level 1 -mdisable-fp-elim -relaxed-aliasing -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 133.3 -v -resource-dir /usr/bin/../lib/clang/4.0 -fmodule-cache-path /var/folders/nb/qkspw0z92f506gbjq9gb505r0000gn/T/clang-module-cache -stdlib=libc++ -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /Users/spott/Documents/Code/ebss/bin -ferror-limit 19 -fmessage-length 272 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/nb/qkspw0z92f506gbjq9gb505r0000gn/T/tut3-9Q4qRh.o -x c++ tut3.cpp 
clang -cc1 version 4.0 based upon LLVM 3.1svn default target x86_64-apple-darwin12.1.0 
ignoring nonexistent directory "/usr/include/c++/v1" 
#include "..." search starts here: 
#include <...> search starts here: 
/usr/bin/../lib/c++/v1 
/usr/local/include 
/usr/bin/../lib/clang/4.0/include 
/usr/include 
/System/Library/Frameworks (framework directory) 
/Library/Frameworks (framework directory) 
End of search list. 
"/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.8.0 -o a.out -L/usr/local/lib/ /var/folders/nb/qkspw0z92f506gbjq9gb505r0000gn/T/tut3-9Q4qRh.o -lboost_filesystem-mt -lboost_system-mt -lc++ -lSystem /usr/bin/../lib/clang/4.0/lib/darwin/libclang_rt.osx.a 
Undefined symbols for architecture x86_64: 
    "boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::codecvt<wchar_t, char, __mbstate_t> const&)", referenced from: 
    boost::filesystem::path::path<boost::filesystem::directory_entry>(boost::filesystem::directory_entry const&, boost::enable_if<boost::filesystem::path_traits::is_pathable<boost::decay<boost::filesystem::directory_entry>::type>, void>::type*) in tut3-9Q4qRh.o 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

我真的不知道是什麼問題,什麼想法?

+0

您是否驗證過您嘗試鏈接的庫實際存在於/ usr/local/lib中? –

+0

也可以發佈詳細的鏈接器輸出,它可能有所幫助。 –

+0

當我回家時,我會發布詳細的鏈接器輸出,但是我可以肯定地說,這些庫確實存在於該位置。 –

回答

2

剛剛在MacOS上使用文件系統時遇到同樣的問題。 「 - STD = C++ 11 -stdlib =的libC++」

/B2 --build-DIR = ../boost_libs工具集=鐺CXXFLAGS =:

無法不與下面的選項編譯升壓經歷linkflags =「 - stdlib = libC++」stage --with-filesystem

這篇文章對我有用:here

+0

你知道傳遞給自制的'brew'命令來啓用這些編譯標誌的標誌嗎?或者我必須手動編輯boost.rb? – Sc0ttyD