在Windows 10下使用mingw构建OpenCV时出错

时间:2017-01-12 18:13:17

标签: windows opencv cmake mingw

我尝试在Windows 10 PC上构建opencv库。 我设法从源代码生成cmake的所有内容。 (没有红色,没有错误)。 当我尝试使用mingw构建所有内容时(mingw32-make install) 它开始构建,一段时间后我得到以下错误。

[ 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

我找到了以下"Error: '::hypot' has not been declared" in cmath while trying to embed Python

但是无法理解。 任何人都可以暗示我的方向。在构建OpenCV的情况下,这些包括哪些内容?

版本: OpenCV 3.2.0, CMake 3.4.1, GNU Make 4.1

任何帮助都值得赞赏!

1 个答案:

答案 0 :(得分:0)

转到以下文件

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

看看是否 #include "Python.h"
来自#include <cmath>之前 在这种情况下,交换订单,即写

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

以便cmath出现在Python.h之前 尝试构建并查看是否在列表中解决了您报告的错误。