Normally, I would say you should create a library. Just use the CMake macro
rosbuild_add_library(foo src/foo.cpp src/bar.cpp)
In this example, a library named libfoo.so is created from files foo.cpp and bar.cpp.
To use your library from other packages, you also need to update your manifest file. In our example, you need to add this:
<export>
<cpp cflags="-I${prefix}/include" lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib -lfoo"/>
</export>
To use your library in another package you can now just depend on your package.
Originally posted by Lorenz with karma: 22731 on 2011-10-25
This answer was ACCEPTED on the original site
Post score: 4
Original comments
Comment by Mac on 2011-10-26:
In every meaningful way, the "build a library and export it" technique is the Right Answer.
Comment by Lorenz on 2011-10-25:
There might be a pretty hacky way by using the rosbuild cmake macros to find the path to a package and some cmake magic to find all object files in that package. But I wouldn't feel good with that solution :)
Comment by raahlb on 2011-10-25:
Yes, I've done that. I was just wondering if there was some easier way to do it. Not that it it is that complex, but still, I was hoping to just link towards the .o files. As far as you know, there is no way to do that?