2014-03-13 6 views
6

Das ist meine CMakeLists.txt Datei:-Boost mit Cmake auf Linux (Ubuntu)

add_definitions(-std=c++11) 
find_package(Boost 1.55.0 COMPONENTS filesystem REQUIRED) 
include_directories(${Boost_INCLUDE_DIRS}) 
add_executable(bst main.cpp) 
target_link_libraries(bst ${Boost_LIBRARIES}) 

Wenn ich cmake .. in meinem build Verzeichnis ausführen, cmake erfolgreich erzeugt Dateien.

Aber wenn ich make in build Verzeichnis laufen bekomme ich folgende Fehler:

[email protected]:~/Documents/boost_test/build$ make 
Scanning dependencies of target bst 
[100%] Building CXX object CMakeFiles/bst.dir/main.cpp.o 
Linking CXX executable bst 
/usr/bin/ld: CMakeFiles/bst.dir/main.cpp.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv' 
//usr/lib/x86_64-linux-gnu/libboost_system.so.1.55.0: error adding  symbols: DSO missing from command line 
collect2: error: ld returned 1 exit status 
make[2]: *** [bst] Error 1 
make[1]: *** [CMakeFiles/bst.dir/all] Error 2 
make: *** [all] Error 2 

in meiner main.cpp Quelldatei i genannt nur boost::filesystem::is_directory Funktion für boost testen.

+2

Add Systemkomponente find_package (Boost-hinzufügen 1.55.0 KOMPONENTEN Dateisystem-System ERFORDERLICH) - Dies sollte helfen –

+0

Vielen Dank Das funktioniert für mich. – amin

Antwort

13

Sie sollten auch boost :: Systembibliothek Komponente in Ihrer CMakeLists.txt Datei

find_package (Boost-1.55.0 COMPONENTS Dateisystem System ERFORDERLICH)

+0

Du verdienst mehr UP mein Freund! – Eraden