Hi,
ich versuche verzweifelt die Boost Library in mein aktuelles C++ Programm einzubinden. Genau genommen geht es nur um die boost::filesystem Bibliotheken. Leider bekomme ich beim Ausführen des Makefiles folgende Fehlermeldung:
CMakeFiles/main.dir/Main.cpp.o: In Funktion `__static_initialization_and_destruction_0(int, int)': Main.cpp:(.text+0x1aa): Nicht definierter Verweis auf `boost::system::generic_category()' Main.cpp:(.text+0x1b6): Nicht definierter Verweis auf `boost::system::generic_category()' Main.cpp:(.text+0x1c2): Nicht definierter Verweis auf `boost::system::system_category()' CMakeFiles/main.dir/Main.cpp.o: In Funktion `boost::filesystem::exists(boost::filesystem::path const&)': Main.cpp:(.text._ZN5boost10filesystem6existsERKNS0_4pathE[_ZN5boost10filesystem6existsERKNS0_4pathE]+0x19): Nicht definierter Verweis auf `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)' CMakeFiles/main.dir/Main.cpp.o: In Funktion `boost::filesystem::is_directory(boost::filesystem::path const&)': Main.cpp:(.text._ZN5boost10filesystem12is_directoryERKNS0_4pathE[_ZN5boost10filesystem12is_directoryERKNS0_4pathE]+0x19): Nicht definierter Verweis auf `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)' CMakeFiles/main.dir/Main.cpp.o: In Funktion `boost::filesystem::detail::dir_itr_imp::~dir_itr_imp()': Main.cpp:(.text._ZN5boost10filesystem6detail11dir_itr_impD2Ev[_ZN5boost10filesystem6detail11dir_itr_impD5Ev]+0x24): Nicht definierter Verweis auf `boost::filesystem::detail::dir_itr_close(void*&, void*&)' CMakeFiles/main.dir/Main.cpp.o: In Funktion `boost::filesystem::directory_iterator::directory_iterator(boost::filesystem::path const&)': Main.cpp:(.text._ZN5boost10filesystem18directory_iteratorC2ERKNS0_4pathE[_ZN5boost10filesystem18directory_iteratorC5ERKNS0_4pathE]+0x57): Nicht definierter Verweis auf `boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, boost::system::error_code*)' CMakeFiles/main.dir/Main.cpp.o: In Funktion `boost::filesystem::directory_iterator::increment()': Main.cpp:(.text._ZN5boost10filesystem18directory_iterator9incrementEv[_ZN5boost10filesystem18directory_iterator9incrementEv]+0x19): Nicht definierter Verweis auf `boost::filesystem::detail::directory_iterator_increment(boost::filesystem::directory_iterator&, boost::system::error_code*)' CMakeFiles/main.dir/Main.cpp.o: In Funktion `boost::filesystem::path::path<char*>(char* const&, boost::enable_if<boost::filesystem::path_traits::is_pathable<boost::decay<char*>::type>, void>::type*)': Main.cpp:(.text._ZN5boost10filesystem4pathC2IPcEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE[_ZN5boost10filesystem4pathC5IPcEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE]+0x22): Nicht definierter Verweis auf `boost::filesystem::path::codecvt()' CMakeFiles/main.dir/Main.cpp.o: In Funktion `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*)': Main.cpp:(.text._ZN5boost10filesystem4pathC2INS0_15directory_entryEEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE[_ZN5boost10filesystem4pathC5INS0_15directory_entryEEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE]+0x22): Nicht definierter Verweis auf `boost::filesystem::path::codecvt()' Main.cpp:(.text._ZN5boost10filesystem4pathC2INS0_15directory_entryEEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE[_ZN5boost10filesystem4pathC5INS0_15directory_entryEEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE]+0x38): Nicht definierter Verweis auf `boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry const&, std::string&, std::codecvt<wchar_t, char, __mbstate_t> const&)' collect2: error: ld returned 1 exit status CMakeFiles/main.dir/build.make:85: recipe for target 'main' failed make[2]: *** [main] Error 1 CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/main.dir/all' failed make[1]: *** [CMakeFiles/main.dir/all] Error 2 Makefile:72: recipe for target 'all' failed make: *** [all] Error 2
Erstelle die Makefile immer mithilfe von CMake. Die CMakeLists.txt sieht folgendermaßen aus:
cmake_minimum_required(VERSION 2.8) project(SearchAndReplace) find_package(Boost REQUIRED) include_directories(${Boost_INCLUDE_DIRS}) add_executable(main Main.cpp) target_link_libraries(main ${Boost_LIBRARY})
Im Programmcode habe ich selbstverständlich auch die <boost::filesystem.hpp> inkludiert. So wies ausschaut liegt das Problem auch eher beim Linker. Könnt ihr mir weiterhelfen? Vielen Dank.