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

rosrun behavior different depending on directory

asked 2012-10-02 09:08:25 -0500

PerkinsJames gravatar image

updated 2012-10-02 09:48:25 -0500

I am using rosrun to run my program that successfully compiles. The program links to another shared object library.

1) If I run it inside the bin/ directory where my executable is using rosrun, it works fine. I use the command:

rosrun MYPROGRAM myprogram

2) If I manually run my ROS node without rosrun ( ./myprogram) it also works fine.

3) If I navigate to any other directory on the system (for example, my ROS workspace) and run

rosrun MYPROGRAM myprogram

I get an error that the shared object library cant be found. Also, running

ldd myprogram

does show the correct linkage on the shared object library. Can anyone enlighten me on the reason why this happens?

Thanks!

update: The shared object library is linked to in the CMakeLists file by a relative directory using

link_directories(../../otherlibrary)

and this library is not located in any kind of system link path.

Update2: It seems the reason is that executables are run from your current directory, and since I linked relative and I try to rosrun from somewhere else, it cant find the relative library. This behavior is apparently different on other systems, and with some compilers it defaults to getting the absolute path when a relative path is given. To make it a little more portable, I used the following cmake directive:

GET_FILENAME_COMPONENT(LIBBASEDIR ../../otherlibrary/ ABSOLUTE)

and then made sure to use ${LIBBASEDIR} in my link_directories.

I would still appreciate any comments anyone may have on this...

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-10-02 11:26:17 -0500

joq gravatar image

Perhaps some of the ROS CMake examples will help you figure out what to do.

If not, please update your question with the exact contents of your CMakeLists.txt.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-10-02 09:08:25 -0500

Seen: 324 times

Last updated: Oct 02 '12