[ros-users] Problem linking to libraries from other Ros packages
Person With question
personwithquestion at yahoo.com
Thu Feb 3 19:46:42 UTC 2011
Ah perfect! Thanks a ton.
Might I recommend an update to the manifest.xml wiki page? The section about the
<export> tag seems a little vague to me. It says what to do, but doesn't say
why. Also, I'm sure an addition tutorial to
the http://www.ros.org/wiki/roscpp/Tutorials page regarding how to link to
libraries in other projects would be very much appreciated by ROS
beginners. Just a thought :)
-Person
________________________________
From: Tully Foote <tfoote at willowgarage.com>
To: User discussions <ros-users at code.ros.org>
Sent: Wed, February 2, 2011 12:43:25 AM
Subject: Re: [ros-users] Problem linking to libraries from other Ros packages
Hi,
The library you are trying to link to is named foo, not A in the CMakeLists.txt
of A. If you export -lfoo insteadof -lA it should work fine. in our example
code we often use ${PROJECT_NAME} for the name of libraries which makes the
library have the same name as the package.
As a side note, you don't need to explicitly link lib A, now foo, to bar in B's
CMakeLists, it's already linked due to the export.
Tully
On Tue, Feb 1, 2011 at 9:25 PM, Person With question
<personwithquestion at yahoo.com> wrote:
Hello,
>
>
>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
>work.
>http://ros-users.122217.n3.nabble.com/linking-shared-library-td862667.html
>http://www.ros.org/wiki/Manifest
>http://www.ros.org/wiki/rosbuild/CMakeLists
>
>
>-Person
>
>
>
>_______________________________________________
>ros-users mailing list
>ros-users at code.ros.org
>https://code.ros.org/mailman/listinfo/ros-users
>
>
--
Tully Foote
Systems Engineer
Willow Garage, Inc.
tfoote at willowgarage.com
(650) 475-2827
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20110203/b09e0246/attachment-0003.html>
More information about the ros-users
mailing list