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?
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.
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
Try
CFLAGS=-fPIC ./configure ...<your config options>...
To add the flag that the error mentions is missing.
(And the question is...?)
Shared libraries must be composed of PIC object code, but ffmpeg failed to do so.
Did you compile your libvpx with --shared
and -fPIC
so it generated libvpx.so*
?
If not, you can try comment #6 and #7 in this issue.
I had this problem in MythTV build with libx264.a
I downloaded and built as Saheed suggested.
The only thing is that /usr/local/lib/libx264.a was not changed when I did "make install". I had to do "make install-lib-static"