Ask Your Question
0

Using a library created using rosbuild_add_library

asked 2014-10-06 04:59:05 -0500

Hemu gravatar image

updated 2014-10-06 08:28:44 -0500

I have created a package in ROS which contains my own header files and I have created a library using these header files using rosbuild_add_library (add_library in case of Catkin) . I wish to make use of this library in another ROS package. Is it enough to add the package ( containing my library ) to the list of dependency in package.xml (or manifest.xml) of the current package and using target_link_libraries( my_target my_library) in CMakeLists.txt or do I have to specify the complete path to my library? In other words, do I have to use link_directories(library_directories) even after adding my former package to the package.xml of the current package?

Pkg1 (package) contains a library foo. The library has been created using rosbuild_add_library on one computer and using add_library (for catkin) on another computer. Pkg2 is the package (created in both computers) in which I want to use the library foo.

edit retag flag offensive close merge delete

Comments

Does Pkg2 use rosbuild or catkin? Why do you have two versions of Pkg1 on two different computers?

BennyRe gravatar image BennyRe  ( 2014-10-06 08:35:00 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-10-06 08:49:06 -0500

Wolf gravatar image

For fuerte you have to add to your manifest.xml of the lib package:

 <export>
  <cpp cflags="-I${prefix}/include"
        lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib -lyour_lib"/>
  </export>

if your headers are placed in the include subfolder for the lib package and the library you creates using rosbulid_add_library is named your_lib like:

rosbuild_abb_library( your_lib src1.cpp src2.cpp )

Your your depenign packages will be automatically compiled against the headers and linked against the lib.

Note: For catkin (groovy and above) the workaround is slightly different. You do not need this in the package.xml but have to use the catkin_package cmake comand in the CMakeLists.txt of your lib package.........

edit flag offensive delete link more

Comments

It worked. I will try using catkin_package command in CMakeLists for the packages built using catkin.

Hemu gravatar image Hemu  ( 2014-10-06 12:21:45 -0500 )edit
1

answered 2014-10-06 05:48:15 -0500

BennyRe gravatar image

Adding a rosbuild_add_library generated library to your package.xml won't work because rosbuild_add_library is rosbuild and package.xml is Catkin. Catkin packages can't depend on rosbuild packages.

edit flag offensive delete link more

Comments

I work with fuerte. So, it is manifest.xml. I just wanted a general idea whether the mentioned way of using the library in another package would work or not. Anyway, I will edit the question.

Hemu gravatar image Hemu  ( 2014-10-06 07:59:15 -0500 )edit
1

Please specify precisely in your original question what the dependent and depending packages are (catkin/rosbuild).

dornhege gravatar image dornhege  ( 2014-10-06 08:04:00 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-10-06 04:59:05 -0500

Seen: 224 times

Last updated: Oct 06 '14