I'm trying to install OpenCV 3.3.0 based on these instructions:
http://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/
But I faced errors while running :
sudo cmake -D CMAKE_BUILD_TYPE=RELEASE
-D CMAKE_INSTALL_PREFIX=/usr/local
-D INSTALL_PYTHON_EXAMPLES=ON
-D INSTALL_C_EXAMPLES=OFF
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules
-D PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python
-D BUILD_EXAMPLES=ON ..
A few minutes ago my cmake command was working properly but I had errors in make -j4
command which was:
/usr/bin/ld: /usr/local/lib/libavformat.a(allformats.o): relocation R_X86_64_32 against `ff_aac_demuxer' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libavformat.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
modules/videoio/CMakeFiles/opencv_videoio.dir/build.make:312: recipe for target 'lib/libopencv_videoio.so.3.3.0' failed
make[2]: *** [lib/libopencv_videoio.so.3.3.0] Error 1
CMakeFiles/Makefile2:4918: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
But After I ran my cmake command with fPIC
It started to show errors on cmake.The command I executed for fPIC
option:
sudo cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules \
-D PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python \
-D BUILD_EXAMPLES=ON \
-D COMPILE_FLAGS+=-fPIC ..
My OS is Ubuntu 16.04 and I want to install openCV with python3 as interface.
Thanks in advance.