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?
Aurora0001
6,3773 gold badges25 silver badges39 bronze badges
-
I ran into that problem a month ago, I fixed it by starting fresh and following this tutorialBenjamin Ashbaugh– Benjamin Ashbaugh2018年04月09日 14:48:40 +00:00Commented Apr 9, 2018 at 14:48
1 Answer 1
Solution is Simple...
- just go to
/usr/include/c++
- chose whatever version you are using. In my case it was 6, So chose folder 6
- look for
cmath.c
and open it. Change#include_next <math.h>
to#include <math.h>
- Save it and done..
If you are having error with stdlib.h
then also do the same for cstdlib.c
file
Solution by abhiAB23 https://github.com/highfidelity/hifi/issues/8047
RalfFriedl
2,1802 gold badges12 silver badges12 bronze badges
answered Feb 15, 2019 at 20:17