参考文章:
cmake 配置参考见以下文章
https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows
https://blog.huihut.com/2017/12/03/CompiledOpenCVRunInQt/
编译过程中遇到的问题:
1.CMP0083 PIE policy warnings for executables are noisy
这个问题主要是因为cmake版本问题,cmake 3.14会有这个问题,详情https://gitlab.kitware.com/cmake/cmake/issues/18955。
切换成最新版的cmake 3.15解决。https://cmake.org/files/v3.15/
2.‘D3D11_TEXTURE2D_DESC’ was not declared in this scope 错误
在cmake config 中可以关闭 WITH_OPENCL_D3D11_NV
这个选项(默认是开的),然后重新 Configure
-Generate
-mingw32-make。
参考https://blog.csdn.net/huihut/article/details/81317102 第五点。
3.file not recognized,recipe for target failed
有两种情况:
第一种情况:Python2版成功,Python3版失败
第二种情况:只有Python3,仍然失败
先取消选中 Build_opencv_python3,后面用到再重新configure
参考:(这篇文章概括的比较全面,强烈推荐)
4.CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAK
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
将CMAKE_MAKE_PROGRAM项后面的路径设置为Qt安装路径下的路径如下所示:MinGW/bin/mingw32-make.exe,重新点击Configure,问题解决!
参考:https://blog.csdn.net/u010189457/article/details/54957309/