# rosbuild and static libraries

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 close merge delete

Sort by » oldest newest most voted

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.

more

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.
( 2011-07-05 02:52:41 -0500 )edit