CMake编译OpenCV-3.0.0源码,使其可以在VS2013下进行图像处理开发最终在编译时失败的过程记录

之前博主尝试着CMake编译OpenCV-4.1.2源码,使其可以在VS2012下进行图像处理开发,最终因为缺少库OpenBLAS而失败。详情见博文:https://blog.csdn.net/wenhao_ir/article/details/124641125

今天准备再尝试下“CMake编译OpenCV-3.0.0源码,使其可以在VS2013下进行图像处理开发”。

由于博文https://blog.csdn.net/wenhao_ir/article/details/124641125对过程已经记录得挺详细的了,所以这篇博文就只作简要记录。

OpenCV-3.0.0源码下载地址:
链接:https://pan.baidu.com/s/16uPy69GiOrlGEataEvrd9A?pwd=dj75

OpenCV-3.0.0扩展库下载地址:
链接:https://pan.baidu.com/s/1RA_sCdp4VekqzE7CNON-zg?pwd=lh3g

准备工作做好,如下图所示:
在这里插入图片描述
打开Cmake,选择好源代码目录和build存放目录:
在这里插入图片描述
然后点击左下角“configure”按钮,选择好平台和目标平台类型。
在这里插入图片描述
点击Finish开始configure

configure的整个过程花费时间不少,时间主要是耗费在了下载文件 ippicv_windows_20141027.zip上,如下图所示:
在这里插入图片描述
最终还是没有下载成功,见下面的报错说明。其实博文中https://blog.csdn.net/wenhao_ir/article/details/124664637首先遇到的也就是这个问题。

第一次报错如下:
在这里插入图片描述
有两处报错:

一个一个错误来分析(日志中的红色部分,不一定是错误)
第一处:

CMake Deprecation Warning at CMakeLists.txt:22 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at CMakeLists.txt:69 (cmake_policy):
  The OLD behavior for policy CMP0022 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:74 (cmake_policy):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:79 (cmake_policy):
  The OLD behavior for policy CMP0042 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

出现以上提示的原因在于OpenCV-3.0.0的源码的Cmake文件是在老版本的Cmake基础上写的,其所用的一些功能会在将来的Cmake版本中去除,所以建议按目前所使用的Cmake版本来重写Cmake。好在上面所有提示的功能在目前的的版本中都还没有被去除,所以我们暂时不用理会这些。

第二处:

ICV: Downloading ippicv_windows_20141027.zip...
CMake Error at 3rdparty/ippicv/downloader.cmake:71 (file):
  file DOWNLOAD HASH mismatch

    for file: [F:/Build-openCV3.0.0/opencv-3.0.0/3rdparty/ippicv/downloads/windows-b59f865d1ba16e8c84124e19d78eec57/ippicv_windows_20141027.zip]
      expected hash: [b59f865d1ba16e8c84124e19d78eec57]
        actual hash: [827569eea3481e6da39d28713cc4309d]
             status: [28;"Timeout was reached"]

Call Stack (most recent call first):
  3rdparty/ippicv/downloader.cmake:108 (_icv_downloader)
  cmake/OpenCVFindIPP.cmake:235 (include)
  cmake/OpenCVFindLibsPerf.cmake:12 (include)
  CMakeLists.txt:526 (include)


CMake Error at 3rdparty/ippicv/downloader.cmake:75 (message):
  ICV: Failed to download ICV package: ippicv_windows_20141027.zip.
  Status=28;"Timeout was reached"
Call Stack (most recent call first):
  3rdparty/ippicv/downloader.cmake:108 (_icv_downloader)
  cmake/OpenCVFindIPP.cmake:235 (include)
  cmake/OpenCVFindLibsPerf.cmake:12 (include)
  CMakeLists.txt:526 (include)

上面的报错是说文件 ippicv_windows_20141027.zip下载失败,看来还是得像博文 https://blog.csdn.net/wenhao_ir/article/details/124664637中那样去网上寻找这几个文件。

经过一番寻找,最终找到了,我把 ippicv_windows_20141027.zip 上传到了CSDN的付费下载区,需要这个文件的朋友可以花费1.9元下载,链接:https://download.csdn.net/download/wenhao_ir/85525449

找这些文件实际是有技巧的,链接 https://blog.csdn.net/wenhao_ir/article/details/125100220 (这个链接中的第1点便是对这个技巧的描述,博主暂时设为仅博主可见,等若干年后博主再公开)

将ippicv_windows_20141027.zip 放于文件夹F:/Build-openCV3.0.0/opencv-3.0.0/3rdparty/ippicv/downloads/windows-b59f865d1ba16e8c84124e19d78eec57/下:
在这里插入图片描述
重新configure,这个错误得到解决。
在这里插入图片描述
接下来根据自己需求进行配置勾选:
我作如下变动:
第一处变动变动前:
在这里插入图片描述
第一处变动变动后:
在这里插入图片描述

这个变动实际上我是用opencv_world代替我勾选的所有库,我之所以这样做,是因为参考官方的发布,也避免自己将来使用时去配置那么多lib文件,下图是官方发布的编译好的库。
在这里插入图片描述
接下来添加扩展库的路径:
F:/Build-openCV3.0.0/opencv_contrib-3.0.0/modules
在这里插入图片描述
然后点击Generate,很快就完成了相应的VS2013工程生成。
在这里插入图片描述
接下来我们打开VS2013进行编译处理。
在这里插入图片描述
在这里插入图片描述
得到一堆报错:
在这里插入图片描述
可见,都是由world引起的,难道我上面对配置的修改有问题,那我就重新来配置一下,这次配置就不做选择性修改了,只把扩展模块路径加上。

首先删除所有文件,然后全部重新解压。同时把ippicv_windows_20141027.zip 放于文件夹F:/Build-openCV3.0.0/opencv-3.0.0/3rdparty/ippicv/downloads/windows-b59f865d1ba16e8c84124e19d78eec57/下,注意,没有downloads和windows-b59f865d1ba16e8c84124e19d78eec57文件夹咱们就自己新建一个就是了。

这个过程的相关截图如下:
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述在这里插入图片描述
接下来再次进入VS2013 进行编译。
在这里插入图片描述

打开之后等待VS2013把解决方案加载和文件相关分析完成,然后咱们开始编译。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
这次编译仍然有问题:
在这里插入图片描述
可见,只成功了9个,失败了88个。

错误一大堆,简直是没法直视…
在这里插入图片描述
与上次Cmake OpenCV-4.1.2源码相比,这次没有出现对OpenBLAS的需求,可见OpenCV3.x可能并不需要OpenBLAS。

这次是OpenCV3.0.0,下篇博文我试下OpenCV3.1.x,如果还是这样的错误,我就把这个问题先放一放。我觉得我的操作应该是没有多大问题的,可能哪天换个开发环境就对了。嗯 ,就这样,先去接孩子吧…

刚才去接孩子的路上,仔细想了想,与其这样去苦苦自己编译,不如直接用别人弄好的,平时注意收集下别人编好的库就行了,要用的时候直接拿来用就是了。

猜你喜欢

转载自blog.csdn.net/wenhao_ir/article/details/125098843