[cmake] Boost
-
Hallo!
Ich versuche in cmake die Boost Library zu verwenden. Dazu folgende CMakeLists.txt:
PROJECT (test) ADD_EXECUTABLE (test test.cpp) FIND_PACKAGE (Boost COMPONENTS thread) TARGET_LINK_LIBRARIES(test ${Boost_THREAD_LIBRARY}) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
Die Makefile-Generierung mit
cmake .
funktioniert, aber beim Compilieren bekomme ich Unmengen an "undefined reference" Fehlern:% make VERBOSE=1 /usr/bin/cmake -H/usr/src/boost_cmake_test -B/usr/src/boost_cmake_test --check-build-system CMakeFiles/Makefile.cmake 0 /usr/bin/cmake -E cmake_progress_start /usr/src/boost_cmake_test/CMakeFiles 1 make -f CMakeFiles/Makefile2 all make[1]: Entering directory `/usr/src/boost_cmake_test' make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/depend make[2]: Entering directory `/usr/src/boost_cmake_test' make[2]: Nothing to be done for `CMakeFiles/test.dir/depend'. make[2]: Leaving directory `/usr/src/boost_cmake_test' make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/build make[2]: Entering directory `/usr/src/boost_cmake_test' /usr/bin/cmake -E cmake_progress_report /usr/src/boost_cmake_test/CMakeFiles 1 [100%] Building CXX object CMakeFiles/test.dir/test.o /usr/bin/c++ -o CMakeFiles/test.dir/test.o -c /usr/src/boost_cmake_test/test.cpp Linking CXX executable test /usr/bin/cmake -P CMakeFiles/test.dir/cmake_clean_target.cmake /usr/bin/c++ -fPIC "CMakeFiles/test.dir/test.o" -o test -rdynamic CMakeFiles/test.dir/test.o: In function `foo::foo()': test.cpp:(.text._ZN3fooC1Ev[foo::foo()]+0x1f): undefined reference to `boost::mutex::mutex()' test.cpp:(.text._ZN3fooC1Ev[foo::foo()]+0xd5): undefined reference to `boost::thread::thread(boost::function0<void, std::allocator<boost::function_base> > const&)' test.cpp:(.text._ZN3fooC1Ev[foo::foo()]+0x1cb): undefined reference to `boost::thread::thread(boost::function0<void, std::allocator<boost::function_base> > const&)' test.cpp:(.text._ZN3fooC1Ev[foo::foo()]+0x249): undefined reference to `boost::mutex::~mutex()' CMakeFiles/test.dir/test.o: In function `boost::detail::thread::lock_ops<boost::mutex>::lock(boost::mutex&)': test.cpp:(.text._ZN5boost6detail6thread8lock_opsINS_5mutexEE4lockERS3_[boost::detail::thread::lock_ops<boost::mutex>::lock(boost::mutex&)]+0x11): undefined reference to `boost::mutex::do_lock()' CMakeFiles/test.dir/test.o: In function `boost::detail::thread::scoped_lock<boost::mutex>::lock()': test.cpp:(.text._ZN5boost6detail6thread11scoped_lockINS_5mutexEE4lockEv[boost::detail::thread::scoped_lock<boost::mutex>::lock()]+0x2c): undefined reference to `boost::lock_error::lock_error()' test.cpp:(.text._ZN5boost6detail6thread11scoped_lockINS_5mutexEE4lockEv[boost::detail::thread::scoped_lock<boost::mutex>::lock()]+0x31): undefined reference to `boost::lock_error::~lock_error()' test.cpp:(.text._ZN5boost6detail6thread11scoped_lockINS_5mutexEE4lockEv[boost::detail::thread::scoped_lock<boost::mutex>::lock()]+0x36): undefined reference to `typeinfo for boost::lock_error' CMakeFiles/test.dir/test.o: In function `boost::detail::thread::lock_ops<boost::mutex>::unlock(boost::mutex&)': test.cpp:(.text._ZN5boost6detail6thread8lock_opsINS_5mutexEE6unlockERS3_[boost::detail::thread::lock_ops<boost::mutex>::unlock(boost::mutex&)]+0x11): undefined reference to `boost::mutex::do_unlock()' CMakeFiles/test.dir/test.o: In function `boost::detail::thread::scoped_lock<boost::mutex>::unlock()': test.cpp:(.text._ZN5boost6detail6thread11scoped_lockINS_5mutexEE6unlockEv[boost::detail::thread::scoped_lock<boost::mutex>::unlock()]+0x2f): undefined reference to `boost::lock_error::lock_error()' test.cpp:(.text._ZN5boost6detail6thread11scoped_lockINS_5mutexEE6unlockEv[boost::detail::thread::scoped_lock<boost::mutex>::unlock()]+0x34): undefined reference to `boost::lock_error::~lock_error()' test.cpp:(.text._ZN5boost6detail6thread11scoped_lockINS_5mutexEE6unlockEv[boost::detail::thread::scoped_lock<boost::mutex>::unlock()]+0x39): undefined reference to `typeinfo for boost::lock_error' CMakeFiles/test.dir/test.o: In function `foo::~foo()': test.cpp:(.text._ZN3fooD1Ev[foo::~foo()]+0x15): undefined reference to `boost::thread::join()' test.cpp:(.text._ZN3fooD1Ev[foo::~foo()]+0x22): undefined reference to `boost::thread::join()' test.cpp:(.text._ZN3fooD1Ev[foo::~foo()]+0x37): undefined reference to `boost::mutex::~mutex()' test.cpp:(.text._ZN3fooD1Ev[foo::~foo()]+0x56): undefined reference to `boost::mutex::~mutex()' collect2: ld returned 1 exit status make[2]: *** [test] Error 1 make[2]: Leaving directory `/usr/src/boost_cmake_test' make[1]: *** [CMakeFiles/test.dir/all] Error 2 make[1]: Leaving directory `/usr/src/boost_cmake_test' make: *** [all] Error 2
Was habe ich falsch gemacht?
MfG
-
PROJECT (test) ADD_EXECUTABLE (test test.cpp) FIND_PACKAGE (Boost) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) TARGET_LINK_LIBRARIES(test boost_thread)