I ran the ./configure
script of FFmpeg as follows:
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --pkg-config-flags="--static" --extra-cflags="-fPIC -m64 -I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-pic --extra-ldexeflags=-pie --enable-shared
When I try to compile FFmpeg with --enable-shared
option as above, I get this error:
/usr/bin/ld: /home/guel/ffmpeg_build/lib/libx264.a(common.o): relocation R_X86_64_32 against '.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/home/guel/ffmpeg_build/lib/libx264.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
I had added --enable-pic
,--extra-ldexeflags=-pie
as well as -fPIC -m64
to --extra-cflags
in order to get rid of this relocation error as suggested here: https://www.ffmpeg.org/platform.html
But I'm still getting the same error. I need to compile ffmpeg with --enable-shared
option to interface it with OpenCV, so I have to find a workaround here.
I managed to solve the problem. Actually, the additions -fPIC
and --enable-pic
should have done the trick, but I stupidly had previously compiled the dependency libraries (libx264 and many others) with --disable-shared
option because I didn't care about it when I first compiled FFmpeg and just blindly followed the compilation guide here: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
After having re-compiled all the libraries with --enable-shared
option, FFmpeg also compiled with that option successfully.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With