ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
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:
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
$ mkdir ~/local $ tar --bzip2 -xf ~/local/boost_1_57_0.tar.bz2
$ 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].