编译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

 

  • 7
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值