Cannot find Boost dependency for ament_cmake

asked 2021-06-17 20:32:04 -0500

ur_10 gravatar image

I have been trying to build a ROS2 package that depends on Boost. Unfortunately, it looks like CMake is unable to find the Boost libraries. The error log is -

  CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find Boost (missing: Boost_INCLUDE_DIR system)
  Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindBoost.cmake:2179 (find_package_handle_standard_args)
  CMakeLists.txt:17 (find_package)

make: *** [Makefile:266: cmake_check_build_system] Error 1

The relevant CMakeLists.txt content is -

find_package(Boost REQUIRED COMPONENTS system)

target_include_directories(local_diagnostic include ${Boost_INCLUDE_DIRS})
target_link_libraries(local_diagnostic ${Boost_LIBRARIES})

add_executable( local_diagnostic src/local_diagnostic.cpp)
edit retag flag offensive close merge delete


Did you install Boost with with -dev suffix? Since it is missing Boost_INCLUDE_DIR running sudo apt install libboost-all-dev may fix the problem.

lukicdarkoo gravatar image lukicdarkoo  ( 2021-06-27 04:37:16 -0500 )edit