1. 程式人生 > >Qt5.11.0+OpenCV3.4.3配置教程

Qt5.11.0+OpenCV3.4.3配置教程

關於詳細配置,可以參考:

本文主要是闡述,在編譯過程遇到的問題及解決方法。

1、

D:\opencv-3.4.3\modules\videoio\src\cap_msmf.cpp:143:28: error: using invalid fi
eld '{anonymous}::ComPtr<T>::p'
         return p.operator&();
                            ^
D:\opencv-3.4.3\modules\videoio\src\cap_msmf.cpp: In instantiation of '{anonymou
s}::ComPtr<T>::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<T>::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