[Libav-user] make shared lib including libav*.a on linux x64 platform

Nick Paul nickpaul at letterboxes.org
Thu Apr 17 13:38:29 CEST 2014

>         I'd like to make a shared library called mylib.so that include
>         static ffmpeg libraries libavcodec.a libavformat.a ..etc. in
>         order to have just one shared library
>         I'm working on a linux machine 64 bit (ubuntu 12.04).
>         I've built ffmpeg libraries from ffmpeg 2.0.1 sources with this
>         configuration:
>         --prefix="$HOME/ffmpeg_build"   --extra-cflags="-m64
>         -I$HOME/ffmpeg_build/include"
>         --extra-ldflags="-L$HOME/ffmpeg_build/lib"  
>         --bindir="$HOME/bin" --extra-libs="-ldl" --enable-gpl
>         --enable-libmp3lame --enable-libx264 --enable-pic
>         When I link the avlibs in mine, with this command:
>         gcc -m64    -o mylib.so  -L../ffmpeg_build/lib
>         /home/uts/ffmpeg_build/lib/libavcodec.a -Wl,-R. -shared -s -fPIC
>         I always get this error:
>         /usr/bin/ld:
>         /home/uts/ffmpeg_build/lib/libavcodec.a(deinterlace.o):
>         relocation R_X86_64_PC32 against symbol `ff_pw_4' can not be
>         used when making a shared object; recompile with -fPIC
>         /usr/bin/ld: final link failed: Bad value
>         The same procedure on a x86 linux platform succeded.
>         This is the same problem experienced from Dayana in this mailing
>         list the 1st may 2013, I read the answers but they were not
>         helpful
>         Can you help me please?
>         thank you
>         Il 28/10/2013 12:37, Carl Eugen Hoyos ha scritto:

Hi there,

I had a similar problem. I believe the cause and problem is explained in 
the following post:


I'm sure it is not the prettiest way to do it, but I used the above 
suggestion in the following patch worked for my scenario of linking static
ffmpeg libs into my own application shared dynamic lib.

It was painful to keep attempting a link to work out which items needed 
modifying but the end result worked like a charm. 


Hope it might help someone else.

More information about the Libav-user mailing list