1

I tried to build the opencv Library on my Windows 10 PC. I managed to generate everything from source with cmake. (Nothing red, no errors). When I try to build everything with mingw (mingw32-make install) It starts building and after a while I get the following error.

[ 76%] Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.obj
In file included from C:/Python34/include/Python.h:8:0,
             from C:\OpenCV\opencv-master\modules\python\src2\cv2.cpp:6:
C:/Python34/include/pyconfig.h:440:5: warning: "_MSC_VER" is not defined [-Wundef]
 #if _MSC_VER >= 1800
 ^~~~~~~~
In file included from C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/6.2.0/include/c++/math.h:36:0,
             from C:/Python34/include/pyport.h:328,
             from C:/Python34/include/Python.h:50,
             from C:\OpenCV\opencv-master\modules\python\src2\cv2.cpp:6:
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/6.2.0/include/c++/cmath:1133:11: error: '::hypot' has not been declared
using ::hypot;
       ^~~~~
modules\python3\CMakeFiles\opencv_python3.dir\build.make:179: recipe for target 'modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.obj' failed
mingw32-make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.obj] Error 1
CMakeFiles\Makefile2:7051: recipe for target 'modules/python3/CMakeFiles/opencv_python3.dir/all' failed
mingw32-make[1]: *** [modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

I found the following "Error: '::hypot' has not been declared" in cmath while trying to embed Python

But could not figured it out. Can Anyone hint me in the direction. Where are those includes in the case of building OpenCV?

Versions: OpenCV 3.2.0, CMake 3.4.1, GNU Make 4.1

Any help qould be appreciated!

Community
  • 1
  • 1
samoncode
  • 466
  • 2
  • 7
  • 23

1 Answers1

0

Go to the following file

C:\OpenCV\opencv-master\modules\python\src2\cv2.cpp  

and see if #include "Python.h"
comes before #include <cmath>.
In that case exchange the order, i.e. write

#include <cmath>
#include "Python.h"   

so that cmath comes before Python.h.
Try to build and see if that solves at list the error that you reported.

fedepad
  • 4,509
  • 1
  • 13
  • 27
  • In my case cmath was not included at all in the file you mentioned. I added it before the Python include and started over again. But nothing changed. http://pastebin.com/uhMJJx8g that is my cv2.cpp file. I noticed that it is complaining about _MSC_VER not beeing declared. Can this be a source of errors? – samoncode Jan 13 '17 at 09:21