ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Why can't CMake find the installed Boost libraries? (Boost-catkin error)

asked 2017-12-06 19:11:49 -0500

M@t gravatar image

updated 2017-12-10 17:59:37 -0500

I'm trying to get the Boost library working with catkin and CMake on Linux (Ubuntu 14.04). CMake can successfully find Boost, but can't find the libraries, instead failing to when running catkin_make with this error:

CMake Error at /usr/share/cmake-3.2/Modules/FindBoost.cmake:1201 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.54.0

  Boost include path: /usr/include

  Could not find the following Boost libraries:


  No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the
  directory containing Boost libraries or BOOST_ROOT to the location of

I've made the necessary edits to my CMakeLists.txt file, as per the wiki page. And I've also searched other ROS/StackOverflow questions here, here and here, however none of these solutions have worked for me.

Boost is definitely installed in the /usr/include/boost folder, and all the libraries are there so I'm not sure why CMake isn't finding them. I've also tried using set() to change BOOST_LIBRARYDIR and BOOST_ROOT in the CMakeList.txt file, but if that's the solution then I haven't found the right filepath to set them to.

When I add set(Boost_DEBUG 1) the compiler spits out more information, including this:

-- [ /usr/share/cmake-3.2/Modules/FindBoost.cmake:1104 ] Boost_FOUND = 1
-- Boost version: 1.54.0
-- Found the following Boost libraries:
--   system
--   filesystem
--   thread
--   date_time
--   iostreams
--   serialization
--   chrono

So it seems that Boost is being found, but it only detects a few libraries. However there are definitely more libraries than those few present in the /usr/include/boost folder, so I'm not sure why only these ones are being found.

My CMakeList.txt file is:

cmake_minimum_required(VERSION 2.8.3)

find_package( PCL REQUIRED)
find_package( catkin REQUIRED COMPONENTS

find_package( Boost REQUIRED COMPONENTS


include_directories( include 

# All the "add_executable" and "link_target_libraries" commands for my .cpp files.

If anyone has any advice or suggestions on how to resolve this problem, I'd be very appreciative.


  1. There are actually two versions of boost installed on my system. v1.54.0 in /usr/include/boost/version.hpp and v1.65.1 in /usr/lib/boost_1_65_1/boost/version.hpp

  2. In response to @gvdhoorn's comment, the output of dpkg -l | grep boost is here: output of grep boost.txt. Note that grep doesn't return anything about v1.65.1

  3. I've noticed that my code will compile and run if I only use v1.54.0 and don't include <boost/core/demangle.hpp> as it seems that v1.54.0 does have the other two files I'm including (<boost/foreach.hpp> and <boost/algorithm/string.hpp>) but not this one.

  4. In response to @gvdhoorn's answer: I added the following lines to my CMakeLists.txt file, to try to force CMake to use version 1.65.1:

    set(BOOST_ROOT /usr/lib ...

edit retag flag offensive close merge delete


/usr/include/boost implies that this is a user-built install of Boost, not one maintained by the package manager / distributed with your OS. Is that correct?

gvdhoorn gravatar image gvdhoorn  ( 2017-12-07 03:35:19 -0500 )edit

I'm not entirely sure sorry, since I've somewhat mindlessly installed so many different packages through the command-line. There are definitely two versions though - 1.54.0 in /usr/include/boost and 1.65.1 in /usr/lib/. 1.65.1 I manually installed, and I can't remember where 1.54.0 came from.

M@t gravatar image M@t  ( 2017-12-07 13:52:09 -0500 )edit

Which OS is this? And I would expect Boost files in both /usr/include/boost as well as /usr/lib: the former are the headers, while the latter are the libraries.

Assuming a debian OS: what is the output of dpkg -l | grep boost?

gvdhoorn gravatar image gvdhoorn  ( 2017-12-07 14:39:35 -0500 )edit

Oops, yes sorry I should have mentioned I'm using Ubuntu 14.04. I'll update my question momentarily. Thanks for your help as always.

M@t gravatar image M@t  ( 2017-12-07 16:02:34 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-12-08 03:01:48 -0500

gvdhoorn gravatar image

updated 2017-12-08 03:11:06 -0500

Note that grep doesn't return anything about v1.65.1

Seeing as you're running Ubuntu Trusty (14.04), I'm pretty certain that the 1.65.x install of Boost was compiled from sources (or came from a PPA, or somewhere else, but not from the official pkgs). Trusty comes with Boost 1.54.

The fact that your code compiles with 1.54 when you don't use demangle.hpp probably makes sense, as that was only introduced in 1.56 (before that it could have been demangled_name.hpp (from here)).

So to summarise:

I believe that CMake is finding Boost alright, but that you're trying to use files that don't exist in the Boost version that CMake finds (ie: 1.54).

If you really want to use the newer Boost, you could try something like find_package(Boost REQUIRED 1.65 COMPONENTS ..). Provided all required files are on CMake's search path, it should ignore 1.54 and go with the newer one.

Note that mixing Boost versions is not recommended at all. There are plenty of questions about that on ROS Answers, so you could take a look at those to read about some potential consequences.

edit flag offensive delete link more

Question Tools



Asked: 2017-12-06 19:11:49 -0500

Seen: 41,637 times

Last updated: Dec 10 '17