ros / ros

Core ROS packages
www.ros.org
BSD 3-Clause "New" or "Revised" License
2.84k stars 782 forks source link

roslib dependency to rospack not exported corretly to CMake? #128

Closed Sarcasm closed 8 years ago

Sarcasm commented 8 years ago

ROS version: Indigo Operating system: Ubuntu Trusty (14.04) roslib package version: ros-indigo-roslib 1.11.13-0trusty-20160627-161857-0700

We notice a compilation issue in our environment. The error happens in the case where we invoke CMake directly (not via catkin) and that the environment (setup.bash) is not sourced. When building a node that depends on roslib (indirectly), we get a linker error:

ld: warning: librospack.so, needed by /opt/ros/indigo/lib/libroslib.so, not found (try using -rpath or -rpath-link)                                                                                    
/opt/ros/indigo/lib/libroslib.so: undefined reference to `rospack::ROSPack::run(std::string const&)'                                                                                     
collect2: error: ld returned 1 exit status                                                                          

Looking at the CMake config for roslib, the error makes sense:

$ grep "set(libraries" /opt/ros/indigo/share/roslib/cmake/roslibConfig.cmake
set(libraries "roslib")

Without going too deep in the roslib package I would expect to have:

set(libraries "roslib;rospack")

Or even:

set(libraries "rospack")

I wanted to propose a patch to add the dependency to the CMakeLists.txt and package.xml, however the information is already present:

Any idea why the roslibConfig.cmake does not list the dependencies of the CMakeLists.txt/package.xml? I do not have a deep understanding of how the whole build is working so I may have made a few wrong assumptions.

dirk-thomas commented 8 years ago

Can you please try to add CATKIN_DEPENDS to the catkin_package(...) call and check if that resolves the problem for you.

Sarcasm commented 8 years ago

I had difficulty to check because I do not build using the Ubuntu built package. I now realize my fix to change the libraries variable is wrong and what needs to be updated is depends.

With your command depends is set properly and the build is working fine.

I have create a PR #129 against kinetic-devel.