编译OpenCV3.4.1时出现的一些问题

使用CMake编译

编译文件夹在opencv安装文件夹下,名字是release 

1.https://blog.csdn.net/huihut/article/details/78701814

D:\opencv\sources\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\sources\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\sources\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

 

 

2.https://blog.huihut.com/2017/12/03/CompiledOpenCVRunInQt/

Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

解决方案:

修改D:\opencv\sources\modules\videoio\src\cap_dshow.cpp文件,在#include "DShow.h"这行的上面加一行#define NO_DSHOW_STRSAFE

然后重新Configure-Generate-mingw32-make

 

3.https://stackoverflow.com/questions/52469349/opencv-io-win32-cc-wfopen-has-not-been-declared-mingw

D:\opencv\sources\3rdparty\protobuf\src\google\protobuf\stubs\io_win32.cc: In function 'FILE* google::protobuf::internal::win32::fopen(const char*, const char*)':
D:\opencv\sources\3rdparty\protobuf\src\google\protobuf\stubs\io_win32.cc:330:10: error: '::_wfopen' has not been declared
   return ::_wfopen(wpath.c_str(), wmode.c_str());
          ^
3rdparty\protobuf\CMakeFiles\libprotobuf.dir\build.make:258: 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:687: 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

解决方案:

修改D:\opencv\release中的CMakeCache.txt,查找CMAKE_CXX_FLAGS,然后把CMAKE_CXX_FLAGS:STRING的值修改为-U__STRICT_ANSI__,即CMAKE_CXX_FLAGS:STRING=-U__STRICT_ANSI__

注意一定不要重新Configure-Generate!! 做了这步操作之后CMakeCache.txt又会重新生成。直接mingw32-make

 

 

 

=====================使用QT时pro文件需要添加的代码================

INCLUDEPATH+=D:\opencv\build\include

LIBS+=-L D:\opencv\release\lib\libopencv_*.a

 

你可能感兴趣的:(存活确认)