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

Revision history [back]

For anyone still interested in this, the problem may have come from the following line:

include_directories(SYSTEM ${Boost_INCLUDE_DIRS}

This will essentially tell CMake to use the default System boost lib (and not the specific one we want).

Here is a complete set of CMake instructions to specify a custom boost version, assuming that the custom boost version directory is in /home/[user]/local/boost-1.57.0 (you have to replace [user] with your own linux-account-specific user-name):

....

find_package(
    catkin 
    REQUIRED COMPONENTS
    rospy
    roscpp
)
set(use_SYSTEM_BOOST TRUE)

if(${use_SYSTEM_BOOST})
    include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
else()    
    set(BOOST_ROOT /home/<user>/local/boost-1.57.0)
    set(Boost_DIR /home/<user>/local/boost-1.57.0)
    set(BOOST_INCLUDEDIR /home/<user>/local/boost-1.57.0/include)
    set(BOOST_LIBRARYDIR /home/<user>/local/boost-1.57.0/lib)
    set(Boost_NO_SYSTEM_PATHS ON)
    set(Boost_ADDITIONAL_VERSIONS "1.57.0")
    find_package(Boost 1.57.0 REQUIRED COMPONENTS thread filesystem log system)
    include_directories(${Boost_INCLUDE_DIRS})
endif()
...
## Specify libraries to link a library or executable target against
target_link_libraries(${PROJECT_NAME}
   ${Boost_LIBRARIES} 
    ${catkin_LIBRARIES}
)

Note that just extracting the content of the .bz2 file is not enough to setup boost. Here is some instructions to set up the boost lib properly in a local directory:

  1. Download boost_1_XX_X.tar.bz2 as per version required:

Note that all version of CMake doesn't have a working version of find_package(Boost ...) for the most recent version of Boost.

    Boost 1.57 works with CMake 3.5.1
    Boost 1.63 requires CMake 3.7 or newer
    Boost 1.64 requires CMake 3.8 or newer
    Boost 1.65 and 1.65.1 require CMake 3.9.3 or newer
  1. Extract content in the directory where you want to put the Boost installation. Extracting in a local directory is recommended (ex. ~/local)
$ mkdir ~/local
$ tar --bzip2 -xf ~/local/boost_1_57_0.tar.bz2
  1. build and install in local dir, creating a new folder called boost-1.XX.X
$ cd ~/local/boost_1_57_0 
$ ./bootstrap.sh --with-libraries="thread,filesystem,log,system" --prefix=/home/<user>/local/boost-1.57.1
$ ./b2 install

Note: you can build all libs by omitting [--with-libraries].