libtool & dependency_libs in *.la files

Richard W.M. Jones rjones at
Fri Nov 26 15:52:37 UTC 2010

[Apologies if this has been covered before, but I cannot find anything
in the archives]

When building a package I noticed that binaries in the package were
still getting unnecessary DT_NEEDED entries.  Example:

  binary ---> depends only on
				 |      libfoo depends on

but the binary was getting built with DT_NEEDED entries for both
'' and '', which is wrong.

ld had the '--no-add-needed' flag, so ld wasn't adding the extra
DT_NEEDED entry.  (See: )

I tracked this down to our old friend libtool.  Basically because the
binary and the library were being built out of the same source tree,
there was a '' file which contained:


and this causes libtool to decide to "helpfully" add -lbar to the
linker command line, even though it is completely unnecessary.

(This is not a problem if libfoo and the binary were in separate
source packages, because we already nuke the *.la files, which avoids
this brokenness across different packages.  The problem is
specifically confined to the case where binaries and libraries are
built from the *same* source package).

I was able to work around this by adding a libtool wrapper which set
dependency_libs='' in the *.la file.

I notice that Debian, Ubuntu and Gentoo have proposed something

except they are unilaterally modifying libtool downstream instead of
using my hackish wrapper, which is a better idea.  Apparently either
no one has tried to get this upstream, or libtool developers weren't


Richard Jones, Virtualization Group, Red Hat
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.

More information about the devel mailing list