I am trying to install OpenCV 3.0.0 on RPi2 with raspbian Stretch. When I run the following
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_V4L=ON ..
and then sudo make, I get the following error:
pi@raspberrypi:~/opencv-3.0.0/build $ sudo make
[ 2%] Built target libtiff
[ 6%] Built target libwebp
[ 10%] Built target IlmImf
[ 10%] Built target opencv_hal_pch_dephelp
[ 10%] Built target pch_Generate_opencv_hal
[ 12%] Built target opencv_hal
[ 12%] Built target opencv_perf_core_pch_dephelp
[ 12%] Generating opencv_imgproc_pch_dephelp.cxx
Scanning dependencies of target opencv_imgproc_pch_dephelp
[ 12%] Building CXX object modules/imgproc/CMakeFiles/opencv_imgproc_pch_dephelp.dir/opencv_imgproc_pch_dephelp.cxx.o
[ 12%] Linking CXX static library ../../lib/libopencv_imgproc_pch_dephelp.a
[ 12%] Built target opencv_imgproc_pch_dephelp
Scanning dependencies of target pch_Generate_opencv_imgproc
[ 12%] Generating precomp.hpp
[ 12%] Generating precomp.hpp.gch/opencv_imgproc_RELEASE.gch
[ 12%] Built target pch_Generate_opencv_imgproc
[ 12%] Built target opencv_core_pch_dephelp
[ 12%] Generating precomp.hpp.gch/opencv_core_RELEASE.gch
In file included from /home/pi/opencv-3.0.0/modules/hal/include/opencv2/hal/defs.h:329:0,
from /home/pi/opencv-3.0.0/modules/core/include/opencv2/core/cvdef.h:59,
from /home/pi/opencv-3.0.0/modules/core/include/opencv2/core.hpp:52,
from /home/pi/opencv-3.0.0/modules/core/include/opencv2/core/utility.hpp:52,
from /home/pi/opencv-3.0.0/build/modules/core/precomp.hpp:49:
/usr/include/c++/6/cmath:45:23: fatal error: math.h: No such file or directory
#include_next <math.h>
^
compilation terminated.
modules/core/CMakeFiles/pch_Generate_opencv_core.dir/build.make:62: recipe for target 'modules/core/precomp.hpp.gch/opencv_core_RELEASE.gch' failed
make[2]: *** [modules/core/precomp.hpp.gch/opencv_core_RELEASE.gch] Error 1
CMakeFiles/Makefile2:1511: recipe for target 'modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
Does anyone know how to solve this?