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

Can't Set RPath

asked 2011-10-13 08:05:18 -0500

Constantin S gravatar image

Hello all, I am having trouble with my CMake file. I am getting a library not found after compiling, so I looked up the documentation for CMake 2.4.6 AND CMake 2.8 (no difference here) for setting your RPATH.

CMake file is as follows:



Checking the property in the same CMake file:

get_target_property(DURPDA RaveServer INSTALL_RPATH)

Revealed the property has been set correctly.

However examination of link.txt and CMakeCache.txt shows my -Wl,-rpath,[my rpath] is not seen anywhere. Has anyone else experienced this?

Thank you

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-10-13 08:15:23 -0500

updated 2011-10-14 03:31:21 -0500

I wouldn't recommend using rpath. The code is not portable as the path to the shared libraries is hard coded in the executable.

The libraries in the lib folder of a package will be discoverable by the linker when you compile your own package. Say for example you have package A, with the folder lib and the library Then if you write package B which depends (in the manifest.xml) on A, any executable in B will link against the libraries in A/lib. To check this, you can type:

ldd your_executable

and see the dependencies in /opt/ros.

Alternatively you can set LD_LIBRARY_PATH to add paths to the loader search list. This can be easily done in a launch file by using:


For more information see the roslaunch xml format.

edit flag offensive delete link more


For now I am resorting to the LD_LIBRARY_PATH, however that is much less portable than setting rpath. Which lib path are you referring to? This shared library is in a ROS stack, so not stored in any of the typical lib folders. Could you elaborate on what is easily done in a launch file? Thank u.
Constantin S gravatar image Constantin S  ( 2011-10-13 09:49:16 -0500 )edit
I have edited my answer, I hope it is more clear now.
Lorenzo Riano gravatar image Lorenzo Riano  ( 2011-10-13 21:00:49 -0500 )edit
So manifest.xml depends also sets run time path? I thought manifest.xml was only ROS specific settings, interesting. I will attempt this. In the end though, the bug still exists no? ROS documentation states it is compatible with CMake 2.4.6, yet INSTALL_RPATH is not functioning. Thank you.
Constantin S gravatar image Constantin S  ( 2011-10-14 03:30:51 -0500 )edit
As far as I know, INSTALL_RPATH is only set when you do a make install. The binaries created by cmake should already have rpath set correctly. Setting LD_LIBRARY_PATH in a launch file should never be necessary.
Lorenz gravatar image Lorenz  ( 2011-10-14 08:22:10 -0500 )edit
Lorenz, I though JustSpiffy was trying to link against libraries not in ROS and not in a standard path. Maybe adding a few info on the initial problem (apart from setting rpath) will help us.
Lorenzo Riano gravatar image Lorenzo Riano  ( 2011-10-14 21:53:23 -0500 )edit
If I read correctly, cmake should always set the build rpath to all libraries used during compilation, so if a project compiles (and links), libraries should be found, even non-ros libs. You are right, adding more context would definitely help :)
Lorenz gravatar image Lorenz  ( 2011-10-14 22:31:23 -0500 )edit

Question Tools


Asked: 2011-10-13 08:05:18 -0500

Seen: 945 times

Last updated: Oct 14 '11