一、安装Qt二、编译opencv三、测试
前置准备:
下载cmake 安装好并配置好bin目录环境变量
下载opencv 源码 一、安装Qt
下载地址:https://download.qt.io/archive/qt/5.14/5.14.2/
或者下载:镜像地址 中国科学技术大学,清华大学,北京理工大学,中国互联网络信息中心
安装选项:(安装大约需要6G)
配置Qt系统环境变量:
E:QtQt5.14.25.14.2mingw73_64bin
E:QtQt5.14.2Toolsmingw730_64bin
并编译:
1、点击Configure 【Configure下载遇到问题查看】 处理所有下载问题直到完成
2、修改如下配置:(使用Search)
ENABLE_CXX11(选中)
WITH_OPENGL(选中)
WITH_QT(选中)
WITH_IPP(不选)
OPENCV_ENABLE_ALLOCATOR_STATS(不选,否则编译报错)
附加:因为写C++,所以将java,python相关的(如:BUILD_opencv_python3等)绑定生成全部取消勾选。
3、点击Configure后,修改Qt相关配置如下:再次Configure,无报错后,再点击Generate(如下图)
内容如下:
E:QtQt5.14.25.14.2mingw73_64libcmakeQt5E:QtQt5.14.25.14.2mingw73_64libcmakeQt5ConcurrentE:QtQt5.14.25.14.2mingw73_64libcmakeQt5CoreE:QtQt5.14.25.14.2mingw73_64libcmakeQt5GuiE:QtQt5.14.25.14.2mingw73_64libcmakeQt5OpenGLE:QtQt5.14.25.14.2mingw73_64libcmakeQt5TestE:QtQt5.14.25.14.2mingw73_64libcmakeQt5Widgets
生成后文件目录如下:(部分截图)
在本文件夹打开终端执行编译与安装:
编译 mingw32-make -j 8
安装 mingw32-make install
编译部分截图如下:
安装部分截图如下:
报错:gcc: error: long: No such file or directory
错误解决:CMake中 OPENCV_ENABLE_ALLOCATOR_STATS 取消勾选
至此编译安装完成,安装目录为:E:opencv3opencvsourcesbuildinstall。
1、配置opencv环境变量:
E:opencv3opencvsourcesbuildinstallx64mingwbin
2、新建Qt工程并配置
INCLUDEPATH += E:opencv3opencvsourcesbuildinstallinclude E:opencv3opencvsourcesbuildinstallincludeopencv2 E:opencv3opencvsourcesbuildinstallincludeopencvLIBS += -L E:opencv3opencvsourcesbuildinstallx64mingwliblibopencv_*.a
*.pro文件
测试
参考:
https://blog.csdn.net/qq_42564908/article/details/108750807
https://blog.csdn.net/Mr_robot_strange/article/details/110677323