我想編譯一個需要Boost的CPP庫。我在Ubuntu下。CMakeLists將不包括提升標頭
在我的文件之一,我包括升壓頭
#include <boost/function.hpp>
這是CMakeLists.txt
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
find_package(Boost COMPONENTS filesystem system serialization REQUIRED)
set(CAN_MASTER_INCLUDE_DIR include)
include_directories(${Boost_INCLUDE_DIR}
${CAN_MASTER_INCLUDE_DIR}
${CAN_MASTER_INCLUDE_DIR}/boost #this is not the boost I'm talking about
${CAN_MASTER_INCLUDE_DIR}/timers_rtpreempt
${CAN_MASTER_INCLUDE_DIR}/timers_unix
${CAN_MASTER_INCLUDE_DIR}/timers_xeno
${CAN_MASTER_INCLUDE_DIR}/unix
)
LINK_DIRECTORIES($ENV{HOME}/Projects/canmaster/bin)
set(CAN_FESTIVAL_CPP drivers/unix/unix.c
drivers/timers_xeno/timers_xeno.c
)
add_library(canfestival ${CAN_FESTIVAL_CPP})
當我嘗試編譯cd buil && cmake .. && make VERBOSE=1
,它返回以下錯誤:
/usr/bin/cmake -H/home/luca/ArmIkarus/canmaster -B/home/luca/ArmIkarus/canmaster/build_cmake --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/luca/ArmIkarus/canmaster/build_cmake/CMakeFiles /home/luca/ArmIkarus/canmaster/build_cmake/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/luca/ArmIkarus/canmaster/build_cmake'
make -f CMakeFiles/canfestival.dir/build.make CMakeFiles/canfestival.dir/depend
make[2]: Entering directory `/home/luca/ArmIkarus/canmaster/build_cmake'
cd /home/luca/ArmIkarus/canmaster/build_cmake && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/luca/ArmIkarus/canmaster /home/luca/ArmIkarus/canmaster /home/luca/ArmIkarus/canmaster/build_cmake /home/luca/ArmIkarus/canmaster/build_cmake /home/luca/ArmIkarus/canmaster/build_cmake/CMakeFiles/canfestival.dir/DependInfo.cmake --color=
Dependee "/home/luca/ArmIkarus/canmaster/build_cmake/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/luca/ArmIkarus/canmaster/build_cmake/CMakeFiles/canfestival.dir/depend.internal".
Scanning dependencies of target canfestival
make[2]: Leaving directory `/home/luca/ArmIkarus/canmaster/build_cmake'
make -f CMakeFiles/canfestival.dir/build.make CMakeFiles/canfestival.dir/build
make[2]: Entering directory `/home/luca/ArmIkarus/canmaster/build_cmake'
/usr/bin/cmake -E cmake_progress_report /home/luca/ArmIkarus/canmaster/build_cmake/CMakeFiles 1
[ 10%] Building C object CMakeFiles/canfestival.dir/drivers/unix/unix.o
/usr/bin/gcc -I/home/luca/ArmIkarus/canmaster/include -I/home/luca/ArmIkarus/canmaster/include/boost -I/home/luca/ArmIkarus/canmaster/include/timers_rtpreempt -I/home/luca/ArmIkarus/canmaster/include/timers_unix -I/home/luca/ArmIkarus/canmaster/include/timers_xeno -I/home/luca/ArmIkarus/canmaster/include/unix -o CMakeFiles/canfestival.dir/drivers/unix/unix.o -c /home/luca/ArmIkarus/canmaster/drivers/unix/unix.c
In file included from /home/luca/ArmIkarus/canmaster/include/can.h:28:0,
from /home/luca/ArmIkarus/canmaster/include/canDispatch.h:23,
from /home/luca/ArmIkarus/canmaster/drivers/unix/unix.c:36:
/usr/include/boost/function.hpp:13:57: fatal error: functional: No such file or directory
compilation terminated.
make[2]: *** [CMakeFiles/canfestival.dir/drivers/unix/unix.o] Error 1
make[2]: Leaving directory `/home/luca/ArmIkarus/canmaster/build_cmake'
make[1]: *** [CMakeFiles/canfestival.dir/all] Error 2
make[1]: Leaving directory `/home/luca/ArmIkarus/canmaster/build_cmake'
make: *** [all] Error 2
似乎沒有包括提升路徑。如果我嘗試用CMakeLists.txt
中的/usr/include
代替${Boost_INCLUDE_DIR}
,情況也是如此。
我該如何解決?
編輯
這是升壓調試的結果:
[email protected]:~/ArmIkarus/canmaster/build_cmake$ cmake -DBoost_DEBUG=ON ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:525 ] Boost not in cache
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:528 ] _boost_TEST_VERSIONS = 1.48.0;1.48;1.47.0;1.47;1.46.1;1.46.0;1.46;1.45.0;1.45;1.44.0;1.44;1.43.0;1.43;1.42.0;1.42;1.41.0;1.41;1.40.0;1.40;1.39.0;1.39;1.38.0;1.38;1.37.0;1.37;1.36.1;1.36.0;1.36;1.35.1;1.35.0;1.35;1.34.1;1.34.0;1.34;1.33.1;1.33.0;1.33
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:530 ] Boost_USE_MULTITHREADED = TRUE
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:532 ] Boost_USE_STATIC_LIBS =
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:534 ] Boost_USE_STATIC_RUNTIME =
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:536 ] Boost_ADDITIONAL_VERSIONS =
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:538 ] Boost_NO_SYSTEM_PATHS =
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:606 ] Declared as CMake or Environmental Variables:
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:608 ] BOOST_ROOT =
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:610 ] BOOST_INCLUDEDIR =
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:612 ] BOOST_LIBRARYDIR =
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:614 ] _boost_TEST_VERSIONS = 1.48.0;1.48;1.47.0;1.47;1.46.1;1.46.0;1.46;1.45.0;1.45;1.44.0;1.44;1.43.0;1.43;1.42.0;1.42;1.41.0;1.41;1.40.0;1.40;1.39.0;1.39;1.38.0;1.38;1.37.0;1.37;1.36.1;1.36.0;1.36;1.35.1;1.35.0;1.35;1.34.1;1.34.0;1.34;1.33.1;1.33.0;1.33
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:667 ] Include debugging info:
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:669 ] _boost_INCLUDE_SEARCH_DIRS = C:/boost/include;C:/boost;/boost/include;/boost;/sw/local/include
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:671 ] _boost_PATH_SUFFIXES = boost-1_48_0;boost_1_48_0;boost-1_48;boost_1_48;boost-1_47_0;boost_1_47_0;boost-1_47;boost_1_47;boost-1_46_1;boost_1_46_1;boost-1_46_0;boost_1_46_0;boost-1_46;boost_1_46;boost-1_45_0;boost_1_45_0;boost-1_45;boost_1_45;boost-1_44_0;boost_1_44_0;boost-1_44;boost_1_44;boost-1_43_0;boost_1_43_0;boost-1_43;boost_1_43;boost-1_42_0;boost_1_42_0;boost-1_42;boost_1_42;boost-1_41_0;boost_1_41_0;boost-1_41;boost_1_41;boost-1_40_0;boost_1_40_0;boost-1_40;boost_1_40;boost-1_39_0;boost_1_39_0;boost-1_39;boost_1_39;boost-1_38_0;boost_1_38_0;boost-1_38;boost_1_38;boost-1_37_0;boost_1_37_0;boost-1_37;boost_1_37;boost-1_36_1;boost_1_36_1;boost-1_36_0;boost_1_36_0;boost-1_36;boost_1_36;boost-1_35_1;boost_1_35_1;boost-1_35_0;boost_1_35_0;boost-1_35;boost_1_35;boost-1_34_1;boost_1_34_1;boost-1_34_0;boost_1_34_0;boost-1_34;boost_1_34;boost-1_33_1;boost_1_33_1;boost-1_33_0;boost_1_33_0;boost-1_33;boost_1_33
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:696 ] location of version.hpp: /usr/include/boost/version.hpp
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:715 ] version.hpp reveals boost 1.46.1
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:808 ] guessed _boost_COMPILER = -gcc46
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:818 ] _boost_MULTITHREADED = -mt
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:861 ] _boost_RELEASE_ABI_TAG = -
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:863 ] _boost_DEBUG_ABI_TAG = -d
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:906 ] _boost_LIBRARY_SEARCH_DIRS = /usr/include/lib;/usr/include/../lib;/usr/include/stage/lib;C:/boost/lib;C:/boost;/boost/boost_1_46_1/lib;/boost/boost_1_46/lib;/boost/lib;/boost;/sw/local/lib
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:977 ] Searching for FILESYSTEM_LIBRARY_RELEASE: boost_filesystem-gcc46-mt-1_46_1;boost_filesystem-gcc46-mt;boost_filesystem-mt-1_46_1;boost_filesystem-mt;boost_filesystem
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:1009 ] Searching for FILESYSTEM_LIBRARY_DEBUG: boost_filesystem-gcc46-mt-d-1_46_1;boost_filesystem-gcc46-mt-d;boost_filesystem-mt-d-1_46_1;boost_filesystem-mt-d;boost_filesystem-mt;boost_filesystem
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:977 ] Searching for SYSTEM_LIBRARY_RELEASE: boost_system-gcc46-mt-1_46_1;boost_system-gcc46-mt;boost_system-mt-1_46_1;boost_system-mt;boost_system
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:1009 ] Searching for SYSTEM_LIBRARY_DEBUG: boost_system-gcc46-mt-d-1_46_1;boost_system-gcc46-mt-d;boost_system-mt-d-1_46_1;boost_system-mt-d;boost_system-mt;boost_system
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:977 ] Searching for SERIALIZATION_LIBRARY_RELEASE: boost_serialization-gcc46-mt-1_46_1;boost_serialization-gcc46-mt;boost_serialization-mt-1_46_1;boost_serialization-mt;boost_serialization
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:1009 ] Searching for SERIALIZATION_LIBRARY_DEBUG: boost_serialization-gcc46-mt-d-1_46_1;boost_serialization-gcc46-mt-d;boost_serialization-mt-d-1_46_1;boost_serialization-mt-d;boost_serialization-mt;boost_serialization
-- [ /usr/share/cmake-2.8/Modules/FindBoost.cmake:1119 ] Boost_FOUND = TRUE
-- Boost version: 1.46.1
-- Found the following Boost libraries:
-- filesystem
-- system
-- serialization
-- Configuring done
-- Generating done
-- Build files have been written to: /home/luca/ArmIkarus/canmaster/build_cmake
[email protected]:~/ArmIkarus/canmaster/build_cmake$ make
Scanning dependencies of target canfestival
[ 10%] Building C object CMakeFiles/canfestival.dir/drivers/unix/unix.o
In file included from /home/luca/ArmIkarus/canmaster/include/can.h:28:0,
from /home/luca/ArmIkarus/canmaster/include/canDispatch.h:23,
from /home/luca/ArmIkarus/canmaster/drivers/unix/unix.c:36:
/usr/include/boost/function.hpp:13:57: fatal error: functional: No such file or directory
compilation terminated.
make[2]: *** [CMakeFiles/canfestival.dir/drivers/unix/unix.o] Error 1
make[1]: *** [CMakeFiles/canfestival.dir/all] Error 2
make: *** [all] Error 2
它看起來像C++標準庫不包含路徑。要使項目使用C++而不管文件擴展名如何,請使用'project(FOOBAR CXX)'。 – pmr
@pmr謝謝,解決了這個問題!你能把它作爲答案發布嗎? – Maverik
我創建了一個新的問題,我更好地解釋了這個新問題:http://stackoverflow.com/questions/13917798/error-in-moving-from-makefile-to-cmake – Maverik