[Ffmpeg-devel] mp3lame : more --as-needed woes

Rich Felker dalias
Thu Nov 2 21:01:58 CET 2006


On Wed, Nov 01, 2006 at 12:41:24AM +0200, Uoti Urpala wrote:
> On Tue, 2006-10-31 at 17:40 -0500, Rich Felker wrote:
> > On Mon, Oct 30, 2006 at 10:50:04AM +0100, Baptiste Coudurier wrote:
> > > gcc -Wl,--warn-common -Wl,--as-needed -pthread -o
> > > /tmp/ffmpeg-conf-15632-14573-3945 /tmp/ffmpeg-conf-6857-14573-19654.o
> > > -lm -lz -ldts -lm -lmp3lame -lm
> > > /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/libmp3lame.so:
> > > undefined reference to `pow'
> > > collect2: ld returned 1 exit status
> 
> > My guess is that these binutls are broken and decide that -lm is
> > unneeded the first time they see it, then don't even consider it the
> > second time they see it... As usual, blame the maintainers. In the
> 
> AFAICT the linker is behaving correctly here. From the ld man page
> description of --as-needed: "Normally, the linker will add a DT_NEEDED
> tag for each dynamic library mentioned  on  the  command line,
> regardless of whether the library is actually needed.  --as-needed
> causes DT_NEEDED tags to only be emitted for libraries that satisfy some
> symbol reference from regular objects which is undefined at the point
> that the library was linked.". Thus if the only references to libm
> functions are in libmp3lame then the linker does the right thing when it
> doesn't add a direct dependency from from the resulting binary to libm.

It should not add the dependency the first time -lm is seen, but it
should add it the _second_ time, after libmp3lame has been linked. If
it doesn't it's broken, IMO, regardless of whether the documentation
regards this brokenness as the intended behavior or not.

> The error above means that the system has a broken libmp3lame.so. It
> should depend on libm instead of relying on the main program to link
> libraries providing the needed symbols.

This is impossible if libmp3lame is a static library. Even with
libtool .la crap, it would fail if what you say is true for static
libs too..

Rich





More information about the ffmpeg-devel mailing list