Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why is --as-needed not explicitly set for ROS workspaces?

Hello everyone,

I'm using ROS with a non-Ubuntu linux distribution and hit unexpected bugs quite regularly. This is my newest discovery and it would be great to see this fixed one way or the other:

rosbuild automatically links all libraries of modules listed in manifest.xml to rosbuild targets. This is obviously bloated, but it's fine in ubuntu, because they decided to make their gcc linker default to --as-needed instead of the official --no-as-needed and only reachable libraries are actually linked.

Normally, this is not even a severe bug, but only adds more unwanted links.. However, gazebo decided to add a /usr/lib/gazebo-X.Y/plugins/ folder for some of their libs and this folder is only added to LD_LIBRARY_PATH when gazebo is actually used. In my case, we have a launch-file-only dependency to gazebo. This adds a lot of gazebo libs to all binaries of the module, but doesn't add the gazebo environment at build time. Without --as-needed this produces a linking error because the gazebo libs require libs in gazebo's plugin folder.

Long story short(er):

It seems like at least rosbuild assumes that gcc uses --as-needed which is a non-official default. Although I don't think these severe linking errors would appear with catkin, I'd say catkin assumes this as well (and it does make sense to do that!). Otherwise people should probably be more careful when using the catkin_LIBRARIES variable.

Is it possible to officially add this LDFLAG to the standard cmake framework for rosbuild/catkin?

Why is --as-needed not explicitly set for ROS workspaces?

Hello everyone,

I'm using ROS with a non-Ubuntu linux distribution and hit unexpected bugs quite regularly. This is my newest discovery and it would be great to see this fixed one way or the other:

rosbuild automatically links all libraries of modules listed in manifest.xml to rosbuild targets. This is obviously bloated, but it's fine in ubuntu, because they decided to make their gcc linker default to --as-needed instead of the official --no-as-needed and only reachable libraries are actually linked.

Normally, this is not even a severe bug, but only adds more unwanted links.. However, gazebo decided to add a /usr/lib/gazebo-X.Y/plugins/ folder for some of their libs and this folder is only added to LD_LIBRARY_PATH when gazebo is actually used. In my case, we have a launch-file-only dependency to gazebo. This adds a lot of gazebo libs to all binaries of the module, but doesn't add the gazebo environment at build time. Without --as-needed this produces a linking error because the gazebo libs require libs in gazebo's plugin folder.

Long story short(er):

It seems like at least rosbuild assumes that gcc uses --as-needed which is a non-official default. Although I don't think these severe linking errors would appear with catkin, I'd say catkin assumes this as well (and it does make sense to do that!). Otherwise people should probably be more careful when using the catkin_LIBRARIES variable.

Is it possible to officially add this LDFLAG to the standard cmake framework for rosbuild/catkin?

-- EDIT -- I ask this question here instead of talking to a ROS package manager directly, because I got absolutely no idea in which package this would have to be added. Any ideas?