I know OpenCV 3.0 is not a release version, yet. I'm trying to evaluate a few features in the 3.0 version for a prototype system we are building. I cloned the latest source code from the git repository and I use the following cmake to build the libraries:
cmake -D BUILD_SHARED_LIBS=ON -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
However, I encounter this issue when it builds the libraries when i do a make:
/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: error: ld returned 1 exit status
make[2]: *** [lib/libopencv_highgui.so.3.0.0] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
I'm not quite sure where to set the -fPIC flag in the CMakeLists.txt. Just a point to note, I have OpenCV 2.4.8 libraries already built and running on my machine. Thanks for taking time to help me out!
Thanks for the answer. I managed to install OpenCV 3.0.0-dev version by removing my existing OpenCV installation. Although this was not required, I removed my previous 2.4.8 library files and managed to compile it. CCMake helped make the decision for the installation much simpler. Use that to decide which libraries you'd like to compile before running make.
Related
I am trying to build an open source library (openCV in this case) from source using cmake and make. However, I run into a linking error
Linking CXX shared library ../../lib/libopencv_videoio.so
/usr/bin/ld: /usr/local/lib/libc.a(lib_a-mallocr.o): relocation R_X86_64_32S against `__malloc_av_' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libc.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
From what I gather, this means make is using the static version of glibc libc.a instead of the dynamic lib.so.6. I'm assuming I need to change a path somewhere in cmake but I'm unsure of where to look. Any help is appreciated.
edit: I'm doing this on a 64 bit linux mint machine
I am using Xubuntu 14.04 and trying to install the latest version of OpenCV, which is 3.0.0 rc1. Briefly, this is the error message I get:
/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
This error message was raised at 41% of the installation, when linking CXX shared library. Before trying to install openCV, first I configured by using cmake without flags. It said that openCV was ready to be installed. I don't know how to solve this problem and I am new to install packages from source. Any help would be appreciated.
I'm Trying to install OpenCV on Ubuntu 14.10 but i'm facing this error again and again :(
/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
modules/highgui/CMakeFiles/opencv_highgui.dir/build.make:654: recipe for target 'lib/libopencv_highgui.so.2.4.9' failed
make[2]: *** [lib/libopencv_highgui.so.2.4.9] Error 1
CMakeFiles/Makefile2:1767: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/all' failed
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
Makefile:133: recipe for target 'all' failed
make: *** [all] Error 2
Please provide the command history before you have encountered the error.
If calling make was the last thing before the error occured, you can try to call make CFLAGS="-fPIC" instead.
Late to the party, but the issue is that FFMPEG is not compiled with position-independent code. Go to your FFMPEG directory and do
./configure --enable-nonfree --enable-pic --enable-shared
then redo the make, make install steps, and re-do the build of opencv.
I am trying to cross compile Opencv for ARM.By using cmake.
I could successfully compile the opencv libraries without enabling the GTK+ support, but when i tried it to enable the GTK+ support (by adding the command -DWITH_GTK=ON ).
Then i am encountered with an error
I am using Ubuntu 14.04, and Opencv version 2.4.9.
I have already installed the GTK library
The cmake command that i used is :
cmake -DSOFTFP=ON -DENABLE_NEON=ON -DWITH_GTK=ON -DCMAKE_TOOLCHAIN_FILE=../arm-gnueabi.toolchain.cmake ../../..
Linking CXX shared library ../../lib/libopencv_highgui.so
/opt/armv7/codesourcery/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../..
/arm-none-linux-gnueabi/bin/ld: cannot find -lgtk-x11-2.0
collect2: ld returned 1 exit status
make[2]: *** [lib/libopencv_highgui.so.2.4.9] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make: *** [all] Error 2
how to fix this problem?
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:
Obtain libavcodec.so and arrange to link against it, or
Remove libavcodec 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
Running a 64-bit version of Ubuntu you have to configure and build ffmpeg with
./configure --enable-shared --enable-pic
as it is described in step 7b and 8b