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

Linking with boost 1.57

asked 2015-03-17 04:51:00 -0500

Hunk gravatar image

updated 2015-03-18 02:45:48 -0500

Hello,

i am using groovy and ubuntu 12.04.

I linked my node with boost 1.55 at the moment, that works fine. Now I have to update to boost 1.57.

CMakeLists.txt

set(Boost_NO_SYSTEM_PATHS TRUE)
set(BOOST_ROOT /opt/boost/boost_1_57)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS}
find_package(Boost 1.57 REQUIRED COMPONENTS thread filesystem log system)

add_executable(test_node src/test.cpp)
 if(TARGET test_node)
 target_link_libraries(test_node
  ${catkin_LIBRARIES}
  ${Boost_LIBRARIES}
 )

The problem is that i get no callback if I send a message, with boost 1.55 it worked well. Does someone have some experience with boost 1.57 and ROS?

Or it is possible to build my application as library with boost 1.57 and use it with ROS?


UPDATE

My second possibility is to split my build process in two CMakelists

CMakelists1.txt (with ROS)

add_subdirectory(test)
add_executable(test_node src/test.cpp)
target_link_libraries(test_node
  ${catkin_LIBRARIES}
  testApplication
 )

CMakelists2.txt (inside test directory , without cmake and ROS)

    set(Boost_NO_SYSTEM_PATHS TRUE)
    set(BOOST_ROOT /opt/boost/boost_1_57)
    include_directories(SYSTEM ${Boost_INCLUDE_DIRS}
    find_package(Boost 1.57 REQUIRED COMPONENTS thread filesystem log system)

    add_library(testApplication STATIC testApplication.cpp)
     if(TARGET testApplication)
     target_link_libraries(testApplication
      ${Boost_LIBRARIES}
     )

Something like this, is this possible?

What is your favourite linking there ? Static or SHARED?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2017-10-17 13:14:52 -0500

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].

edit flag offensive delete link more
0

answered 2015-03-17 20:32:51 -0500

tfoote gravatar image

There are no known issues with Boost 1.57. That seems like an unusual failure mode possibly suggesting there's a different issue such as network setup.

edit flag offensive delete link more

Comments

Ok thanks, is it possible to build my application(no ros depencys) with boost 1.57 and use ROS for communication ? I edited my question above

Hunk gravatar image Hunk  ( 2015-03-18 02:36:38 -0500 )edit

If you want to use the c++ ros client library you will need to link against it. And it will need to be built with the same version of boost as your application. Note, there are some ordering issues in your cmake as well as significant missing elements i'm assuming you're leaving out.

tfoote gravatar image tfoote  ( 2015-03-18 14:24:38 -0500 )edit

That is only an example cmake i know it will not run like this :) I dont have to link my ros client with boost. My Ros node is only for communication and my application implements the algorithm( needs boost 1.57). Is that possible? Then i dont have to link boost with my node or?

Hunk gravatar image Hunk  ( 2015-03-19 04:20:09 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-03-17 04:51:00 -0500

Seen: 2,447 times

Last updated: Mar 18 '15