cmake+opencv+mingw部分error解决

cmake+opencv+mingw部分error解决

  • 前言:
  • 参考资料:
  • 环境&版本:
  • 配置流程:
    • 第一步:配置MinGW-w64
    • 第二步:配置OpenCV
    • 其他:
    • 最后一步:运行demo

前言:

刚刚开始学习, 配置过程踩了很多坑,在爬坑过程中发现这方面的资料不多,所以分享出来,方便大家开发。还有很多不懂的和不足,希望得到大家的补充,相互学习。

参考资料:

科学上网
https://blog.csdn.net/qq_36430621/article/details/71080799
https://github.com/opencv/opencv/issues/12444
https://github.com/hybridgroup/gocv/issues/349
https://github.com/opencv/opencv/issues/10974
https://blog.csdn.net/fengxueniu/article/details/77478669
http://answers.opencv.org/question/62580/not-able-to-build-opencv3-rc1-with-debug-build-type/
https://www.cnblogs.com/ganjiqi/p/8651350.html

环境&版本:

win10
opencv3.4.5
mingw5.3.0
sunlime text(版本不记得了,这个影响不大)

配置流程:

流程我参考的:https://blog.csdn.net/qq_36430621/article/details/71080799
建议像我这样的小白,严格跟着链接中的步骤一步一步走
这里就不复制粘贴了,链接中有的字看不到的话CTRL+A
但是按照这个流程走下来还是遇见很多错,在这里主要记录发现的问题的解决办法

第一步:配置MinGW-w64

报错信息摘要:

jmemmgr.c:662:11: error 'SIZE_MAX' undeclared

这个问题有的资料说在:

/usr/include/jasper/jas_math.h

文件中缺少SIZE_MAX 的定义,需要我们在这个文件#include 下一行中加入

#include 
#include 

#if ! defined SIZE_MAX
#define SIZE_MAX (4294967295U)
#endif

但是我在增加相关信息后仍报相同错误,然后我把mingw的版本换成了5.3.0就好了,也就是再安装mingw的时候Version不要选择默认给的最新的。(参考链接:https://github.com/opencv/opencv/issues/12444)
cmake+opencv+mingw部分error解决_第1张图片

第二步:配置OpenCV

报错信息摘要:

D:\Opencv_Tools\opencv\sources\3rdparty\protobuf\src\google\protobuf\stubs\io_win32.cc|94|error: 'nullptr' was not declared in this scope| #10974

依照链接中的步骤走到第二步的时候,我们需要在第一次Configure的时候,search检索下“ENABLE_CXX11”这个选项,勾选后再次configure,进度条走完后点generate。这样再mingw32-make就不会报错了(参考链接:https://github.com/opencv/opencv/issues/10974)
cmake+opencv+mingw部分error解决_第2张图片

其他:

报错信息摘要:

opencv 43% DShow.h:33:0 capdshow.cpp

截图
cmake+opencv+mingw部分error解决_第3张图片
在opencv的源码文件cap_dshow.cpp中添加(参考:https://blog.csdn.net/fengxueniu/article/details/77478669)

#define STRSAFE_NO_DEPRECATE

最后一步:运行demo

build文件的配置参考(https://blog.csdn.net/qq_36430621/article/details/71080799 ),这里不做赘述,下面是我的sublime-build文件,3-10行需要根据个人文件真实情况进行修改

{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}",
"-I", "E:/OpenCV/opencv/build/include",
"-I", "E:/OpenCV/opencv/build/include/opencv",
"-I", "E:/OpenCV/opencv/build/include/opencv2",
"-L", "E:/OpenCV/opencv/build/x64/mingw/lib",
"-l", "libopencv_core345", "-l", "libopencv_imgproc345", "-l", "libopencv_calib3d345","-l","libopencv_objdetect345",
"-l", "libopencv_video345", "-l", "libopencv_features2d345", "-l", "libopencv_ml345", "-l", "libopencv_highgui345",
"-l", "libopencv_flann345", "-l", "libopencv_imgcodecs345", "-l", "libopencv_photo345", "-l", "libopencv_shape345",
"-l", "libopencv_stitching345", "-l", "libopencv_superres345", "-l", "libopencv_videoio345", "-l", "libopencv_videostab345"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++, source.cpp",
"encoding": "gbk",
"variants":
[
{
"name": "Run",
"cmd" : ["${file_path}/${file_base_name}"]
}
]
}

报错:
cmake+opencv+mingw部分error解决_第4张图片
参考链接:
https://www.cnblogs.com/ganjiqi/p/8651350.html
把后缀是.dll的文件复制到:“C:\Windows\SysWOW64”和“C:\Windows\System32”中

PS:回头才发现就这么几个问题我解决了一天
在这里插入图片描述

你可能感兴趣的:(图像识别)