I am trying to install Opencv 3.2.0 on Ubuntu 16.04 with Python 2.7 bindings. The Fabric script works perfectly when I install Opencv 3.1.0 in this way, but when I try 3.2.0 I receive the following error:
[ 83%] Building CXX object modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o
In file included from /srv/envs/anim8/local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:4:0, from /srv/envs/anim8/local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18, from /root/opencv-3.2.0/modules/python/src2/cv2.cpp:10: /srv/envs/anim8/local/lib/python2.7/site-packages/numpy/core/include/numpy/npy_common.h:17:5: warning: "NPY_INTERNAL_BUILD" is not defined [-Wundef]
#if NPY_INTERNAL_BUILD
^
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
modules/python2/CMakeFiles/opencv_python2.dir/build.make:320: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o' failed
make[2]: ***
[modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o] Error 4
CMakeFiles/Makefile2:20394: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/all' failed
make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
I am using a Fabric script, I have included the relevant section below:
cv_ver = '3.2.0'
sudo('apt-get install -y build-essential cmake pkg-config')
sudo('apt-get install -y python-pip python-dev libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev zlib1g-dev')
sudo('apt-get install -y zip unzip')
sudo('apt-get install -y libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev')
sudo('apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev')
sudo('apt-get install -y libxvidcore-dev libx264-dev')
sudo('sudo apt-get install -y libgtk-3-dev')
sudo('apt-get install -y libatlas-base-dev gfortran')
sudo('apt-get install -y python2.7-dev python3.5-dev')
with cd('~/'):
run('wget -O opencv.zip https://github.com/Itseez/opencv/archive/{cv_ver}.zip'.format(cv_ver=cv_ver))
run('unzip opencv.zip')
run('wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/{cv_ver}.zip'.format(cv_ver=cv_ver))
run('unzip opencv_contrib.zip')
with cd('~/opencv-{cv_ver}/'.format(cv_ver=cv_ver)):
run('mkdir build')
with cd('~/opencv-{cv_ver}/build/'.format(cv_ver=cv_ver)):
run('pip install numpy')
run('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-{cv_ver}/modules \
-D PYTHON_EXECUTABLE={venv}/bin/python \
-D BUILD_EXAMPLES=ON ..'.format(
venv=configuration.VIRTUALENV_PATH,
cv_ver=cv_ver)
)
run('make')
sudo('make install')
sudo('ldconfig')
Any help would be greatly appriciated.