I'm trying to compile OpenCV version 2.3.1 on an Ubuntu 11.10 following instructions described here. I'm getting following error. Can't understand what is happening... /usr/local/lib/libavcodec.a
exists but linker can't link against it, or something else?
error:
[ 20%] Built target pch_Generate_opencv_highgui
Linking CXX shared library ../../lib/libopencv_highgui.so
/usr/bin/ld: /usr/local/lib/libavcodec.a(avpacket.o): relocation R_X86_64_32S against `av_destruct_packet'
can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libavcodec.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
The problem is that you are attempting to link libopencv_highgui.so
with libavcodec.a
. The latter is built from code compiled without -fPIC
(which is quite usual), and such code can not be linked into shared libraries on x86_64
.
Your choices are:
libavcodec.so
and arrange to link against it, orlibavcodec
or -lavcodec
from the link line completely.For the first, you most likely just need to install libavcodec-dev package.
If you do the second, you will still have to arrange for symbols that libopencv_highgui.so
needs from libavcodec
to be available at runtime. You can achieve that by linking the main executable with libavcodec
(either archive or shared variant).
my take would be that, first run sudo apt-get remove libavcodec , then re-install with sudo apt-get install libopencv-dev
I once had similar issue, and the above resolved it
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