Ask Your Question
0

ament_export_dependencies(Boost) not working?

asked 2019-08-19 18:47:39 -0500

DanRose gravatar image

I'm trying to use a library that depends on boost, and it doesn't seem like boost is properly being pulled in as a recursive dependency. How do I properly export the dependency on boost for downstream packages?

My build fails with:

/usr/bin/ld: CMakeFiles/slam_karto.dir/src/slam_karto.cpp.o: undefined reference to symbol '_ZN5boost6detail23get_current_thread_dataEv'
//usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1: error adding symbols: DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [slam_karto] Error 1
make[1]: *** [CMakeFiles/slam_karto.dir/all] Error 2
make: *** [all] Error 2
---
Failed   <<< slam_karto [ Exited with code 2 ]

From my library CMake:

cmake_minimum_required(VERSION 3.5)
project(open_karto)
find_package(Boost REQUIRED COMPONENTS thread)
include_directories(include)
add_library(karto SHARED src/Karto.cpp src/Mapper.cpp)
ament_target_dependencies(karto Boost)
ament_export_include_directories(include)
ament_export_libraries(karto)
ament_export_dependencies(Boost)

From the consuming package CMakeLists.txt:

ament_target_dependencies(slam_karto
  open_karto
  )

I can make the error go away by changing the consuming package to have the following, but this is very bad practice:

find_package(Boost REQUIRED COMPONENTS thread)
ament_target_dependencies(slam_karto
  open_karto
  Boost
  )
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-09-06 12:22:39 -0500

Dirk Thomas gravatar image

The API docs of the ament_export_dependenciesfunctions (https://github.com/ament/ament_cmake/...) describes the requirements what you can pass to it.

In your case of using Boost and requiring the component thread a simple find_package(Boost REQUIRED) call isn't sufficient. Since the API doesn't know about the COMPONENTS thread part it won't use it when downstream packages find your package and as a consequence they will fail to find the Boost thread symbols.

You will need to create a custom CMake file which finds the right component of Boost and register that file as a CONFIG_EXTRAS(see https://github.com/ament/ament_cmake/...).

edit flag offensive delete link more

Comments

So what needs to go in the custom CMake file for Boost? What properties are being ignored by ament's dependency mechanism?

DanRose gravatar imageDanRose ( 2019-09-07 09:12:35 -0500 )edit
1

Since ROS 2 tried to use newer C++ features instead of Boost where possible I don't have an example at hand. A similar case exporting TinyXML2 instead of Boost can be found here: https://github.com/ros/pluginlib/blob... and https://github.com/ros/pluginlib/blob...

Dirk Thomas gravatar imageDirk Thomas ( 2019-09-08 01:09:07 -0500 )edit

Thanks! I wrote up an issue here: https://github.com/ament/ament_cmake/...

It would be nice to have a solution in ament rather than coding up a wrapper for each component-based CMake package. I definitely don't have the knowledge right now to make a PR myself.

DanRose gravatar imageDanRose ( 2019-09-08 03:02:09 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-08-19 18:47:39 -0500

Seen: 29 times

Last updated: Sep 06