How to find dependencies on shared objects in ROS2?
I'm trying to build ROS2 nodes using Bazel, similar to what https://github.com/nicolov/ros-bazel has done for ROS1. The core idea there is to use a binary installation (already present in /opt/ros/galactic
or fat archive downloaded by Bazel automatically) and crawl that to extract information necessary to create Bazel targets for individual packages.
My basic approach is this:
- Go over each directory in
share
. - Check its
cmake/ament_cmake_export_dependencies-extras.cmake
andcmake/ament_cmake_export_libraries-extras.cmake
for_exported_dependencies
and_exported_libraries
, respectively. This way I can find the.so
this target exports and other targets it depends on.
This seems to mostly work. However, some dependencies I don't know how to trace. For example, how do I pull in libspdlog.so.1
? It looks like this belongs to the package spdlog_vendor
, but I don't see that expressed in CMake files or package.xml
. Another example is rmw_cyclonedds_cpp
. This needs a couple of iceoryx*.so
files, but they don't seem to be mentioned anywhere.
For now I work around this by manually providing the missing information, but I would really like to automate the process as much as possible. One thing I considered was running ldd
on the libraries and extracting the required info from its output. I'm pretty sure this would work, but I wonder if there's a better way. Any hints? Thanks!