问题描述#include <boost/format.hpp>失败
在复现slam十四讲第五讲的代码,运行建立点云图的代码时,调用boost库的时候总是失败
CMakeLists.txt
<code>cmake_minimum_required(VERSION 3.17)
find_package(Sophus REQUIRED)
include_directories(${Sophus_INCLUDE_DIRS})
find_package(Pangolin REQUIRED)
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
add_executable(joinMap joinMap.cpp)
# 为什么在这要用Sophus::Sophus 为什么有的是_LIBS 有的是LIBRARIES
target_link_libraries(joinMap ${OpenCV_LIBS} ${Pangolin_LIBRARIES} ${Boost_LIBRARIES})
target_link_libraries(joinMap Sophus::Sophus)
</code>
错误:Could NOT find Boost (missing: Boost_INCLUDE_DIR)
<code>/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/leohao/Documents/YBU/Slam/ch5 CMake Error at /Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message): Could NOT find Boost (missing: Boost_INCLUDE_DIR) Call Stack (most recent call first): /Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE) /Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.17/Modules/FindBoost.cmake:2166 (find_package_handle_standard_args) rgbd/CMakeLists.txt:7 (find_package) -- Configuring incomplete, errors occurred! See also "/Users/leohao/Documents/YBU/Slam/ch5/cmake-build-debug/CMakeFiles/CMakeOutput.log". [Finished] </code>
解决方案
<code>set(BOOST_ROOT /Users/leohao/Documents/lib/boost_1_74_0) </code>
将这句写在find_package(Boost REQUIRED)前
问题原因
CMake版本太旧。CMake无法检测到不同Boost库之间的依赖关系。可能更新CMake,它也将正常工作。
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!