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

rosbuild and static libraries

asked 2011-06-24 12:40:58 -0500

andrew-unit gravatar image

updated 2011-06-27 01:48:05 -0500

I have the following problem. I am trying to use the excellent ros build system for a project not related to ROS. But I'm having troubles with the build system with regard to static libraries and executables.

Package A builds a static executable that is dependent on packages B and C, where B and C build static libraries. I have explicitly modified my rosconfig.cmake to build static libraries and executables.

Package A is a very simple package that has a simple main() function and links against B and C.

If I go into package B and edit a .c file, and then do a rosmake packageA, the build system does indeed build the .c file into a new .a file when the rosmake packageB runs. But it seems there is no way to tell packageA that it should be dependent on the .a file that is made by packageB so that if it sees a new .a file it should rebuild packageA. Even though the build system was smart enough to go down to packageB and recompile the .c file into a .a file, it seems it is not smart enough to inform packageA that it has to relink against packageB's new .a file.

Is it true that the ROS "dependency" system is not able to specify dependencies at the library level when using static libraries? Or am I just crazy!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2011-07-01 08:09:29 -0500

Brian Gerkey gravatar image

Try exporting the full path to the archive library from package B, e.g.:

 <export>
   <cpp cflags="-I${prefix}/include" lflags="${prefix}/lib/libB.a"/>
 </export>

That does the trick for me.

To have the correct dependencies setup, CMake needs to know that it's an archive library, instead of a shared library. It can't do this from a -lfoo argument, but it can do it from a full path to libfoo.a. In fact, the emerging best practice for CMake is to always give it the full path to libraries.

edit flag offensive delete link more

Comments

An elegant solution that does the trick for me as well. I had been hacking on the public.cmake file trying to forcibly add dependencies in the rosbuild_add_executable function (without success). Thanks for your help.
andrew-unit gravatar image andrew-unit  ( 2011-07-05 02:52:41 -0500 )edit

Question Tools

Stats

Asked: 2011-06-24 12:40:58 -0500

Seen: 1,120 times

Last updated: Jul 01 '11