Qt5.11.0+OpenCV3.4.3配置教程

 

关于详细配置,可以参考:

OpenCV使用CMake和MinGW的编译安装及其在Qt配置运行

https://blog.csdn.net/sinat_36264666/article/details/73200739

 

本文主要是阐述,在编译过程遇到的问题及解决方法。

1、

D:\opencv-3.4.3\modules\videoio\src\cap_msmf.cpp:143:28: error: using invalid fi
eld '{anonymous}::ComPtr::p'
         return p.operator&();
                            ^
D:\opencv-3.4.3\modules\videoio\src\cap_msmf.cpp: In instantiation of '{anonymou
s}::ComPtr::operator bool() [with T = IMFMediaSource]':
D:\opencv-3.4.3\modules\videoio\src\cap_msmf.cpp:969:115:   required from here
D:\opencv-3.4.3\modules\videoio\src\cap_msmf.cpp:152:33: error: using invalid fi
eld '{anonymous}::ComPtr::p'
         return p.operator!=(NULL);

 答:将 WITH_IPP  和  WITH_MSMF  取消选中

 

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 ...

 

解决方案:
修改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 错误

表现
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
 

解决方案:

在 cmake-gui 编译配置中:

  • 勾选 ENABLE_CXX11

然后重新Configure-Generate-mingw32-make

 

参考:https://blog.csdn.net/huihut/article/details/78701814

你可能感兴趣的:(QT,图像处理,opencv)