I'm putting together a little OpenCV install on Ubuntu 13.10, and it looks like something is unhappy. I've been through a few versions and install methods, and when I go "make" or "make -j4" the make trucks along until
/usr/bin/ld: /usr/local/lib/libavcodec.a(avpacket.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/libavcodec.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libopencv_videoio.so.3.0.0] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2
Any help is appreciated. Thanks again, Robert.
I had the same problem while compiling opencv3 alpha on Ubuntu 14.04 with FFMPEG enabled.
My FFMPEG was the git version compiled with
./configure
make
make install
I had to recompile FFMPEG with
./configure --enable-nonfree --enable-pic --enable-shared
That did the trick for me and after that opencv3 compiled fine.
OpenCV did not find the right ffmpeg lib when link /usr/local/lib/libavcodec.a
into lib/libopencv_videoio.so.3.0.0
.
A libavcodec.so
should be provided, but opencv only find a libavcodec.a
.
Why? there are some possibilities:
1) Old/New ffmpeg
An old ffmpeg with only static libs is installed in /usr/local/lib
and /usr/local/bin
.
A new ffmpeg with shared lib and customised install path is installed, but system does not know that.
You have to follow http://code.opencv.org/issues/1077 .
2) No shared ffmpeg
You should install ffmpeg with shared lib as other people said.
3) new ffmpeg is not "correctly" install
If new ffmpeg is built by source code and in a customise path, the path should be a absolute path. For example:
/configure --prefix="$HOME/lib/ffmpeg_build"
If a relative path is set, the relative path will be installed into ffmpeg setting file, and opencv will not find right libs according to the file.
You maybe want to look into CMakeCache
file in the opencv source directory, it records libs paths need in building.
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