ffmpeg install on CentOS 64-bit 'install with -fPIC' error

15,319

Solution 1

Since you configured FFMPEG with "--enable-shared", you also need to configure some of it's other libraries with "--enable-shared" also, and they must all use the same setting.

This error message is basically telling you to compile libvpx again with "--enable-shared" added to the configure command, then try compiling FFMPEG again (also configured with "--enable-shared"). Chances are that you will then get the same error but it will say "libx264" or "libmp3lame" instead of "libvpx", so you will also need to recompile those libs with "--enable-shared" in the configure command.

Solution 2

I got a similar error while compiling ffmpeg on an x86_64 machine running Oracle Linux 6.3. Oracle Linux is based on Red Hat and is thus similar to CentOS in the original question.

configure:

./configure --enable-shared --enable-nonfree --enable-libmp3lame --enable-libfaac --enable-libx264 --enable-encoder=x264 --enable-gpl

make:

/usr/bin/ld: /usr/local/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
/usr/local/lib/libx264.a: could not read symbols: Bad value

In my case, this answer, although partly specific to Ubuntu, shed more light on the underlying issue with respect to x86_64 systems in general:

"I believe if you enable-shared on FFmpeg you have to do the same on x264 on x86_64 systems, otherwise you'll have a PIC shared FFmpeg and non-PIC static x264."

The fix was to ensure the x264 sources which I originally compiled using the "--enable-static" flag with configure (which generated "/usr/local/lib/libx264.a") was re-compiled using the "--enable-shared" flag which generates the correct target of "/usr/local/lib/libx264.so":

1st Attempt:
    1. cd /tmp
    2. wget ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
    3. tar xfv last_x264.tar.bz2; 
    4. cd x264-snapshot-xxxxxx
    5. ./configure --enable-static
    6. make && make install

2nd Attempt:
    1. cd /tmp/x264-snapshot-xxxxxx
    2. make distclean
    3. ./configure --enable-shared
    4. make && make install

Solution 3

Try

CFLAGS=-fPIC ./configure ...<your config options>...

To add the flag that the error mentions is missing.

Share:
15,319
ndmweb
Author by

ndmweb

Updated on June 09, 2022

Comments

  • ndmweb
    ndmweb almost 2 years

    I get this error when attempting to compile ffmpeg on a 64bit CentOS machine.

    Here are my ./configure options:

    ./configure --enable-shared --enable-gpl --enable-nonfree --enable-postproc --enable-swscale --enable-pthreads --enable-libx264 --enable-libxvid --enable-libvorbis --enable-libfaac --enable-libmp3lame --enable-libvpx

    make

    I get the following error when compiling the source:

    /usr/bin/ld: /usr/local/lib/libvpx.a(vpx_codec.c.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    /usr/local/lib/libvpx.a: could not read symbols: Bad value
    collect2: ld returned 1 exit status
    make: *** [libavcodec/libavcodec.so.54] Error 1
    

    How do I get around this error, and get libvpx up and running with the latest ffmpeg on my 64-bit CentOS box?

  • ndmweb
    ndmweb about 12 years
    sorry i thought the question was implied. How do I get around this error, and get libvpx up and running with the latest ffmpeg on my 64-bit machine?
  • Mustafa Alammar
    Mustafa Alammar about 10 years
    This worked for me. The key was to use this flag when building/installing x264/libx264 as well.
  • Hitesh
    Hitesh over 9 years
  • Hitesh
    Hitesh over 9 years
  • Hitesh
    Hitesh over 9 years
  • MrTJ
    MrTJ almost 6 years
    indeed this answer tells you what to do instead of just giving you a diagnosis