2012-04-09 10 views
2

Ich benutze OS X 10.7.3. Ich habe jetzt eine Zeit lang mit den Boost-Header zu spielen und ich wollte jedoch auf mit der Boost.Filesystem lib bewegen hält es diese Nachricht an mich zu werfen:Der Versuch, Boost.Filesystem zu verwenden, scheint jedoch nicht zu verlinken?

Undefined symbols for architecture x86_64: 
    "boost::system::generic_category()", referenced from: 
     __static_initialization_and_destruction_0(int, int)in ccOhIhNG.o 
     boost::filesystem3::detail::create_directories(boost::filesystem3::path const&,  boost::system::error_code*)in libboost_filesystem.a(operations.o) 
     boost::filesystem3::detail::canonical(boost::filesystem3::path const&,  boost::filesystem3::path const&, boost::system::error_code*)in  libboost_filesystem.a(operations.o) 
    "boost::system::system_category()", referenced from: 
     __static_initialization_and_destruction_0(int, int)in ccOhIhNG.o 
     (anonymous namespace)::error(bool, boost::system::error_code const&,  boost::filesystem3::path const&, boost::system::error_code*, std::basic_string<char,  std::char_traits<char>, std::allocator<char> > const&)in libboost_filesystem.a(operations.o) 
     (anonymous namespace)::error(bool, boost::filesystem3::path const&,  boost::system::error_code*, std::basic_string<char, std::char_traits<char>,  std::allocator<char> > const&)in libboost_filesystem.a(operations.o) 
     (anonymous namespace)::error(bool, boost::filesystem3::path const&,  boost::filesystem3::path const&, boost::system::error_code*, std::basic_string<char,  std::char_traits<char>, std::allocator<char> > const&)in libboost_filesystem.a(operations.o) 
     boost::filesystem3::detail::dir_itr_close(void*&, void*&)in  libboost_filesystem.a(operations.o) 
     boost::filesystem3::detail::directory_iterator_increment(boost::filesystem3::directory_itera tor&, boost::system::error_code*)in libboost_filesystem.a(operations.o) 
     boost::filesystem3::detail::directory_iterator_construct(boost::filesystem3::directory_itera tor&, boost::filesystem3::path const&, boost::system::error_code*)in  libboost_filesystem.a(operations.o) 
     ... 
ld: symbol(s) not found for architecture x86_64 
collect2: ld returned 1 exit status 

ich das, wenn ich versuche, mit zu kompilieren Dies ist:

Also ging ich zurück zu den boost.org Tutorials und probierte das Regex-Beispiel aus. Es funktionierte perfekt dies mit:

g++ -o test main.cpp -I -l/opt/local/include ~/boost/libs/libboost_regex.a 

Antwort

4

versuchen

g++ -o test main.cpp -I/opt/local/include -L/opt/local/lib -lboost_filesystem 
+0

Er kehrte diesen Fehler: 'Nicht definierte Symbole für Architektur x86_64: "boost :: system :: generic_category()", verwiesen von: __static_initialization_and_destruction_0 (int, int) in ccWyCTY8.o „boost :: system :: system_category()“, verwiesen von: __static_initialization_and_destruction_0 (int, int) in ccWyCTY8.o ld: Symbol (e) nicht für die Architektur x86_64 collect2 gefunden: ld zurück Exit-Status 1 ' –

+1

es sieht aus wie Sie libboost_system fehlt sind auch. Füge einfach '-lboost_system' hinzu. – juanchopanza

+0

heiliger Mist, vielen Dank! –

4

Ihre Compiler-Flags scheinen ein wenig ab. Im Allgemeinen wird die folgende Taste gedrückt halten:

-I // Sets the path for the relevant header files 
-L // Sets the path where your libraries reside 
-l // specifies the library you want to link against. 

Also, wenn Sie eine Bibliothek namens mylib in ~/Libs haben/und müssen Header-Dateien in sich verwenden ~/umfassen, würden Sie passieren

-I ~/include -L ~/libs -lmylib 

als Flags für den Compiler.

+0

danke, das ist alles klar gemacht. Ich hatte keine Ahnung, was sie wirklich waren, wenn ich ehrlich bin. Prost. –

Verwandte Themen