I am using rosrun to run my program that successfully compiles. The program links to another shared object library.
- If I run it inside the bin/ directory where my executable is using rosrun, it works fine. I use the command:
rosrun MYPROGRAM myprogram
If I manually run my ROS node without rosrun ( ./myprogram) it also works fine.
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...
Originally posted by PerkinsJames on ROS Answers with karma: 506 on 2012-10-02
Post score: 0