Error: library x not found - ld cannot find lib (SOLUTION)

Questions that occur when trying to compile FFmpeg.
Post Reply
Envy
Posts: 2
Joined: Thu Jul 07, 2011 7:34 pm

Error: library x not found - ld cannot find lib (SOLUTION)

Post by Envy » Thu Jul 07, 2011 7:53 pm

Hello,

I just had some issues compiling ffmpeg with libmp3lame enabled under cygwin, and I figured that I would share my experiences in case anyone else has this issue in the future.

I first installed libmp3lame using the source at http://sourceforge.net/projects/lame/fi ... z/download

Then did:

Code: Select all

./configure
make
make install
I then went and tried to install ffmpeg using the following option:

Code: Select all

./configure --enable-gpl --enable-libmp3lame --disable-yasm --enable-static --disable-shared
Subsequently, I received the following error:
ERROR: libmp3lame >= 3.98.3 not found

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
[email protected] mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solving the problem.
The config.log file shows the issue happens when the configure script is looking for the libmp3lame library:
check_lib lame/lame.h lame_set_VBR_quality -lmp3lame
check_header lame/lame.h
check_cpp
BEGIN /tmp/ffconf.lHUyXISc.c
1 #include <lame/lame.h>
2 int x;
END /tmp/ffconf.lHUyXISc.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U__STRICT_ANSI__ -std=c99 -fno-common -fomit-frame-pointer -E -o /tmp/ffconf.71L0Fhi8.o /tmp/ffconf.lHUyXISc.c
check_func lame_set_VBR_quality -lmp3lame
check_ld -lmp3lame
check_cc
BEGIN /tmp/ffconf.lHUyXISc.c
1 extern int lame_set_VBR_quality();
2 int main(void){ lame_set_VBR_quality(); }
END /tmp/ffconf.lHUyXISc.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U__STRICT_ANSI__ -std=c99 -fno-common -fomit-frame-pointer -c -o /tmp/ffconf.71L0Fhi8.o /tmp/ffconf.lHUyXISc.c
gcc -Wl,--as-needed -o /tmp/ffconf.q1U1Mk7e.exe /tmp/ffconf.71L0Fhi8.o -lmp3lame -lm -lz -lpsapi
/usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lmp3lame
collect2: ld returned 1 exit status
ERROR: libmp3lame >= 3.98.3 not found
OK... So it can't find libmp3lame.a - where is libmp3lame.a?

Looking back at the make install log from libmp3lame:
test -z "/usr/local/lib" || /usr/bin/mkdir -p "/usr/local/lib"
/bin/sh ../libtool --mode=install /usr/bin/install -c 'libmp3lame.la' '/usr/lo
cal/lib/libmp3lame.la'
/usr/bin/install -c .libs/libmp3lame.dll.a /usr/local/lib/libmp3lame.dll.a
base_file=`basename ${file}`
dlpath=`/bin/sh 2>&1 -c '. .libs/'${base_file}'i;echo $dlname'`
dldir=/usr/local/lib/`dirname $dlpath`
test -d $dldir || mkdir -p $dldir
/usr/bin/install -c .libs/cygmp3lame-0.dll $dldir/cygmp3lame-0.dll
chmod a+x $dldir/cygmp3lame-0.dll
/usr/bin/install -c .libs/libmp3lame.lai /usr/local/lib/libmp3lame.la
/usr/bin/install -c .libs/libmp3lame.a /usr/local/lib/libmp3lame.a
chmod 644 /usr/local/lib/libmp3lame.a
ranlib /usr/local/lib/libmp3lame.a
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-LLIBDIR' linker flag

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
Awesome... so we need to tell gcc to make sure to look in /usr/local/lib.

The following ./configure options solved this issue:
./configure --enable-gpl --enable-libmp3lame --disable-yasm --enable-static --disable-shared --extra-ldflags=-L/usr/local/lib
Hope this post is helpful!

cmt
Posts: 4
Joined: Thu Jul 14, 2011 2:42 pm

Re: Error: library x not found - ld cannot find lib (SOLUTIO

Post by cmt » Sun Jul 17, 2011 5:10 pm

Hi,
thanks for providing this nice solution :)

Unfortunately, this "fix" does not seem to work for me - after applying it, I still get this error message saying "libmp3lame >= 3.98.3 not found" when I run configure (btw, I´m using a 64bit Ubuntu Virtual Machine).

Here are the commands i execute:
./configure --prefix=/home/cmt/ffmpeg/built/ --enable-postproc --enable-runtime-cpudetect --target-os=mingw32 --arch=i386 --cross-prefix=i586-mingw32msvc- --enable-memalign-hack --enable-static --enable-libmp3lame --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib
As you can see, I´ve also added a reference to lame´s include dir as suggested here: http://www.freebsdonline.com/content/view/496/506/



Looking at the config.log file, it says:
check_lib lame/lame.h lame_set_VBR_quality -lmp3lame
check_header lame/lame.h
check_cpp
BEGIN /tmp/ffconf.DgwQYVG2.c
1 #include <lame/lame.h>
2 int x;
END /tmp/ffconf.DgwQYVG2.c
i586-mingw32msvc-gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U__STRICT_ANSI__ -I/usr/local/include -std=c99 -fno-common -fomit-frame-pointer -E -o /tmp/ffconf.ix00MwiP.o /tmp/ffconf.DgwQYVG2.c

check_func lame_set_VBR_quality -lmp3lame
check_ld -lmp3lame
check_cc
BEGIN /tmp/ffconf.DgwQYVG2.c
1 extern int lame_set_VBR_quality();
2 int main(void){ lame_set_VBR_quality(); }
END /tmp/ffconf.DgwQYVG2.c
i586-mingw32msvc-gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U__STRICT_ANSI__ -I/usr/local/include -std=c99 -fno-common -fomit-frame-pointer -c -o /tmp/ffconf.ix00MwiP.o /tmp/ffconf.DgwQYVG2.c
i586-mingw32msvc-gcc -L/usr/local/lib -Wl,--as-needed -o /tmp/ffconf.CfU9sUsK.exe /tmp/ffconf.ix00MwiP.o -lmp3lame -lm -lpsapi
/tmp/ffconf.ix00MwiP.o:ffconf.DgwQYVG2.c:(.text+0xc): undefined reference to `_lame_set_VBR_quality'
collect2: ld returned 1 exit status
ERROR: libmp3lame >= 3.98.3 not found
So for some strange reason, configure has some trouble checking lame´s "set_lame_set_VBR_quality"-function.

Any idea what I´m might doing wrong?

Envy
Posts: 2
Joined: Thu Jul 07, 2011 7:34 pm

Re: Error: library x not found - ld cannot find lib (SOLUTIO

Post by Envy » Wed Jul 27, 2011 9:12 pm

cmt

My first guess is, are you using the latest version of libmp3lame? Or rather, is your compiler looking for the latest version of libmp3lame in the correct location?

First, look for any previous versions of libmp3lame and remove them.

Then, check to ensure that the symbol is defined within the library itself by using nm:
nm /path/to/library/folder/libmp3lame.so | grep set_VBR_quality
You should see something like:
00000750 T _lame_set_VBR_quality
If you do not, re-install lame.

Try that for now and keep us posted on your progress!

cmt
Posts: 4
Joined: Thu Jul 14, 2011 2:42 pm

Re: Error: library x not found - ld cannot find lib (SOLUTIO

Post by cmt » Tue Aug 09, 2011 4:13 pm

Envy

thanks for your fast reply.

I have been busy during the past time, but I finally managed to try out your suggested steps :).

First, I´m using the latest developer version of FFmpeg from Sourceforge (3.98.4).

Second, I ran nm which gave me the following result:
000297d0 T lame_set_VBR_quality
Looking at your output, I noticed that there´s an underscore missing in front of "lame_set" in my version.
And looking back at my original config log, it´s exactly this missing underscore configure complains about.

That´s all for now...

Post Reply