既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新
需要这些体系化资料的朋友,可以加我V获取:vip1024c (备注嵌入式)
- 勾选
WITH_QT
- 勾选
WITH_OPENGL
点击 Configure,再次配置:
- 不勾选
WITH_IPP
- 设置
QT_MAKE_EXECUTABLE
为E:\Qt\Qt5.9.3\5.9.3\mingw53_32\bin\qmake.exe
- 设置
Qt5Concurrent_DIR
为E:\Qt\Qt5.9.3\5.9.3\mingw53_32\lib\cmake\Qt5Concurrent
- 设置
Qt5Core_DIR
为E:\Qt\Qt5.9.3\5.9.3\mingw53_32\lib\cmake\Qt5Core
- 设置
Qt5Gui_DIR
为E:\Qt\Qt5.9.3\5.9.3\mingw53_32\lib\cmake\Qt5Gui
- 设置
Qt5Test_DIR
为E:\Qt\Qt5.9.3\5.9.3\mingw53_32\lib\cmake\Qt5Test
- 设置
Qt5Widgets_DIR
为E:\Qt\Qt5.9.3\5.9.3\mingw53_32\lib\cmake\Qt5Widgets
- 设置
Qt5OpenGL_DIR
为E:\Qt\Qt5.9.3\5.9.3\mingw53_32\lib\cmake\Qt5OpenGL
- 设置
CMAKE_BUILD_TYPE
为Release
或者RelWithDebInfo
点击 Generate 生成 Makefile
编译 OpenCV
打开终端进行编译:(-j
是使用 8
个线程进行编译,请根据你的计算机配置合理设置线程数)
E:
cd E:\OpenCV_3.3.1\opencv-build
mingw32-make -j 8
mingw32-make install
如果 mingw32-make -j 8
遇到错误,请看下面的 编译 OpenCV 常见错误,否则执行 mingw32-make install
,完成安装。
编译 OpenCV 常见错误
0. 多线程编译错误信息不明确
表现
如果使用了多线程编译,导致错误,但是错误信息不明确,如:
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
解决
使用单线程编译:
mingw32-make
以查看详细的错误提示,再根据具体情况解决。
1. RC 错误
表现
... windres.exe: unknown option -- W ...
或者
FORMAT is one of rc, res, or coff, and is deduced from the file name
extension if not specified. A single file name is an input file.
No input-file is stdin, default rc. No output-file is stdout, default rc.
解决
在 cmake-gui 编译配置中:
- 不勾选
ENABLE_PRECOMPILED_HEADERS
然后重新 Configure
-Generate
-mingw32-make
2. sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA 错误
表现
...opencv/sources/modules/videoio/src/cap_dshow.cpp...
... 'sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA' was not declared in this scope ...
或者
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
解决
修改E:\OpenCV_3.3.1\opencv\sources\modules\videoio\src\cap_dshow.cpp
文件,在#include "DShow.h"
这行的上面加一行#define NO_DSHOW_STRSAFE
,如:
#define NO_DSHOW_STRSAFE
#include "DShow.h"
然后重新 Configure
-Generate
-mingw32-make
3. identifier ‘nullptr’ is a keyword in C++11 错误【2018年3月2日编译OpenCV 3.4.1时遇到并解决】
表现
D:\opencv-3.4.1\opencv-3.4.1\3rdparty\protobuf\src\google\protobuf\stubs\io_win32.cc:94:3: warning: identifier 'nullptr' is a keyword in C++11 [-Wc++0x-compat]
return s == nullptr || *s == 0;
^
D:\opencv-3.4.1\opencv-3.4.1\3rdparty\protobuf\src\google\protobuf\stubs\io_win32.cc: In function 'bool google::protobuf::internal::win32::{anonymous}::null_or_empty(const char_type*)':
D:\opencv-3.4.1\opencv-3.4.1\3rdparty\protobuf\src\google\protobuf\stubs\io_win32.cc:94:15: error: 'nullptr' was not declared in this scope
return s == nullptr || *s == 0;
^
3rdparty\protobuf\CMakeFiles\libprotobuf.dir\build.make:412: recipe for target '3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/stubs/io_win32.cc.obj' failed
mingw32-make[2]: *** [3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/stubs/io_win32.cc.obj] Error 1
CMakeFiles\Makefile2:710: recipe for target '3rdparty/protobuf/CMakeFiles/libprotobuf.dir/all' failed
mingw32-make[1]: *** [3rdparty/protobuf/CMakeFiles/libprotobuf.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
解决
在 cmake-gui 编译配置中:
- 勾选
ENABLE_CXX11
然后重新 Configure
-Generate
-mingw32-make
4. ‘chmod’ 不是内部或外部命令,也不是可运行的程序 或批处理文件 | ‘chmod’ is not recognized as an internal or external command【2019年9月2日编译OpenCV 3.4.7时遇到并解决】
表现
'chmod' 不是内部或外部命令,也不是可运行的程序 或批处理文件
原因
在 E:\opencv-3.4.7\opencv-3.4.7\cmake\OpenCVPCHSupport.cmake
中使用了 chmod
命令,然而 Windows 下不支持 chmod
命令,因此报错。
解决
判断系统是否 Windows,若是 Windows,则不使用 COMMAND chmod +x "${_pch_generate_file_cmd}"
,如我提的 PR 中的修改:fix ‘chmod’ is not recognized as an internal or external command in Windows #15433
修改后再重新 Configure
-Generate
-mingw32-make
5. test_common.hpp: No such file or directory【2019年9月2日编译OpenCV 3.4.7时遇到并解决】
表现
In file included from <command-line>:0:0:
E:/opencv-3.4.7/opencv-3.4.7-build/modules/dnn/test_precomp.hpp:50:10: fatal error: test_common.hpp: No such file or directory
#include "test_common.hpp"
^~~~~~~~~~~~~~~~~
compilation terminated.
解决
方法一:(issues/15381)
在 cmake-gui 编译配置中:
- 不勾选
ENABLE_PRECOMPILED_HEADERS
(禁用预编译头)
然后重新 Configure
-Generate
-mingw32-make
方法二:
把 E:\opencv-3.4.7\opencv-3.4.7\modules\dnn\test\test_common.hpp
复制到 E:\opencv-3.4.7\opencv-3.4.7-build\modules\dnn\
目录下
然后继续 mingw32-make
添加 OpenCV 编译的库到环境变量
- 为系统变量
Path
添加E:\OpenCV_3.3.1\opencv-build\install\x86\mingw\bin
新建 OpenCV 的 Qt 项目
在 .pro
文件里面添加:
win32 {
INCLUDEPATH += E:\OpenCV_3.3.1\opencv-build\install\include
LIBS += E:\OpenCV_3.3.1\opencv-build\install\x86\mingw\bin\libopencv_*.dll
}
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新
需要这些体系化资料的朋友,可以加我V获取:vip1024c (备注嵌入式)
5892612470)]
[外链图片转存中…(img-usAjjmNH-1715892612470)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新
需要这些体系化资料的朋友,可以加我V获取:vip1024c (备注嵌入式)