1.先安装QT mingw版
2.下载cmake和opencv源码
3.添加 MinGW 到环境变量
为系统变量 Path
添加 E:\Qt\Qt5.9.3\Tools\mingw530_32\bin
4.使用 CMake 生成 OpenCV 的 Makefile
打开 cmake-gui,设置源码和生成路径:
- Where is the source code:
E:/OpenCV_3.3.1/opencv/sources
- Where to build the binaries:
E:/OpenCV_3.3.1/opencv-build
点击 Configure,设置编译器
- Specify the generator for this project:
MinGW Makefiles
- Specify native compilers
- Next
- Compilers C:
E:\Qt\Qt5.9.3\Tools\mingw530_32\bin\gcc.exe
- Compilers C++:
E:\Qt\Qt5.9.3\Tools\mingw530_32\bin\g++.exe
- Finish
编译配置:
- 勾选
WITH_QT
- 勾选
WITH_OPENGL
- 不勾选
WITH_IPP
点击 Configure,再次配置:
- 设置
QT_MAKE_EXECUTABLE
为