[ros-users] Problem linking to libraries from other Ros packages

Person With question personwithquestion at yahoo.com
Wed Feb 2 05:25:52 UTC 2011


I am having trouble figuring out how to include libraries from other packages I 
have written. I have attached a minimal example of my problem.

I have package A that contains foo.cpp and foo.h, and I have package B that 
contains bar.cpp from which it tries to call a function in foo.cpp. I have 
placed foo.h in "include/A/foo.h", and all cpp files are in their respective 
"src" folders. I have configured the manifests of package A and B as follows:

---- A ----
+ <export>
+   <cpp cflags="-I${prefix}/include" lflags="-Wl,-rpath,${prefix}/lib 
-L${prefix}/lib -lA"/>·
+ </export>
---- B ----
+ <depend package="A"/>

...and I have configured the CMakeLists.txt of packages A and B as follows:
---- A ----
+ rosbuild_add_library(foo src/foo.cpp)
---- B ----
+ rosbuild_add_executable(bar src/bar.cpp)
+ target_link_libraries(bar A)

It seems that I have no trouble including "A/foo.h" from bar.cpp, but I cannot 
use any of the functions. When I try to compile package B, I get the error 
"/usr/bin/ld: cannot find -lA" What am I doing wrong?

I would very much appreciate it if someone could point me in the right 
direction, or email a new attachment with the fixed source. I've followed the 
advice in the following links, but have had no luck getting this example to 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/ros-users/attachments/20110201/2aa7948e/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ros-problem.tar
Type: application/x-tar
Size: 51200 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/ros-users/attachments/20110201/2aa7948e/attachment-0004.tar>

More information about the ros-users mailing list