[ros-users] Compiling ROS statically

Peter Soetens peter at thesourceworks.com
Thu Apr 29 10:50:57 UTC 2010


On Wednesday 28 April 2010 18:40:30 Brian Gerkey wrote:
> 2010/4/27 Srećko Jurić-Kavelj <srecko.juric-kavelj at fer.hr>:
> > What's the status on compiling ROS statically? Here
> > (http://www.ros.org/wiki/gumros#Installing_the_ROS-libraries_on_the_Gumst
> >ix) it says it's not quite possible. It could be very practical for things
> > like this http://amor-ros-pkg.googlecode.com/files/readRosBagScan.cpp.
> 
> hi Srećko,
> 
> I had a look at it this morning, and fixed a couple of problems.  But
> we still have the issue described in
> https://code.ros.org/trac/ros/ticket/912 : we rely on the dependencies
> that the linker writes into shared libs.
> 
> E.g., if you look at the roslib package, it builds libroslib.  In the
> CMakeLists.txt, we tell the linker that libroslib uses librt:
>   target_link_libraries(roslib rt)
> If we're building libroslib.so, then the linker adds a dependency
> libroslib.so -> librt.so (which you can see by running ldd on
> libroslib.so).  Linking an executable against libroslib.so works fine,
> because it implicitly pulls in librt.so.
> 
> But if we're building libroslib.a, then there's nowhere for the linker
> to write down the connection to librt.a.  Instead, we have to remember
> that any time we link against libroslib.a, we also must link against
> librt.a.  Otherwise, the link will fail because of unresolved symbols
> in libroslib.a.
> 
> We can solve this for roslib by having it export "-lroslib -lrt"
> instead of just "-lroslib".  Unfortunately, in general, this means
> duplicating the link information in the CMakeListst.txt and
> manifest.xml.  Furthermore, in the CMakeLists.txt, there may be logic
> deciding what to link against (this is actually the case for roslib,
> which only links against librt if not on OS X); there's not a good way
> to offer the same programmatic control over linking in the
> manifest.xml.
> 
> I don't have a good solution to this problem.  Any suggestions?

I would go for the suggestion I've heard somewhere before: generate the link 
dependencies in a .pc file next to each manifest.xml file.  The pkg-config format 
allows to exactly specify this: private libs (librt) and public libs ( things 
you need to link against if you include any header of roslib ). 

It would be great if the manifest.xml file did not need to contain these (hand 
coded) export arguments, but have that generated automatically. We could 
migrate to such a solution by falling back to scanning the manifest.xml file in 
case no .pc file is found.

Thoughts ?

Peter



More information about the ros-users mailing list