FFmpeg does not compile with shared libraries

I ran the ./configure script 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 the --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 added --enable-pic , --extra-ldexeflags=-pie , as well as -fPIC -m64 in --extra-cflags to get rid of this move error, as suggested here: https://www.ffmpeg.org /platform.html

But I still get the same error. I need to compile ffmpeg with the --enable-shared option to associate it with OpenCV, so I need to find a workaround here.

+5
source share
1 answer

I managed to solve the problem. In fact, the -fPIC and --enable-pic add-ons should have done the trick, but I stupidly compiled the dependency libraries (libx264 and many others) with the --disable-shared option because I didnโ€™t like it when I first compiled FFmpeg and just blindly follow the assembly guide here: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

After recompiling all libraries with the --enable-shared option, FFmpeg is also compiled with this option.

+6
source

Source: https://habr.com/ru/post/1232286/


All Articles