CMake编译OpenCV-3.2.0源码,使其可以在VS2013下进行图像处理开发的失败过程记录
Posted 昊虹图像算法
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CMake编译OpenCV-3.2.0源码,使其可以在VS2013下进行图像处理开发的失败过程记录相关的知识,希望对你有一定的参考价值。
承接博文 https://blog.csdn.net/wenhao_ir/article/details/125098843,本次博主用OpenCV-3.2.0的源码进行Cmake,希望能成功。
先到官网下载OpenCV-3.2.0的源码,当前时间2022-06-02下它在第6页,链接如下:
https://opencv.org/releases/page/6/
百度网盘下载链接:
链接:https://pan.baidu.com/s/1yGdUnk29_nrDNw2KM3tLgw?pwd=fhdv
然后把它的扩展库源码也下载好。
github下载链接如下:
https://github.com/opencv/opencv_contrib/releases/tag/3.2.0
百度网盘下载链接如下:
链接:https://pan.baidu.com/s/1s6EaatW2b_FXOemgpTGG1g?pwd=k4qd
下载完成后,创建相关目录并解压。
打开Cmake,然后按下面的截图操作:
很快报错,报错如下:
CMake Error at cmake/OpenCVCompilerOptions.cmake:21 (else):
Flow control statements are not properly nested.
Call Stack (most recent call first):
CMakeLists.txt:495 (include)
Flow control statements are not properly nested.
翻译过来的意思是:未正确嵌套流程控制语句。每个语言的流程控制语句都是那几个,if…else…是最主要的,我们去看一下是不是这条语句出问题了。
打开文件:F:\\build-opencv3.2.0\\opencv-3.2.0\\cmake\\OpenCVCompilerOptions.cmake
看下第21行
我去,这是谁写的,怎么同一个if下有两个else呢 直接把第二个else去掉吧,即把第21行第22行注释掉吧。
继续configure,依然是缺那几个文件:
Downloading opencv_ffmpeg.dll...
CMake Error at cmake/OpenCVUtils.cmake:1043 (file):
file DOWNLOAD HASH mismatch
for file: [F:/build-opencv3.2.0/opencv-3.2.0/3rdparty/ffmpeg/downloads/f081abd9d6ca7e425d340ce586f9c090/opencv_ffmpeg.dll]
expected hash: [f081abd9d6ca7e425d340ce586f9c090]
actual hash: [d41d8cd98f00b204e9800998ecf8427e]
status: [6;"Couldn't resolve host name"]
Call Stack (most recent call first):
3rdparty/ffmpeg/ffmpeg.cmake:10 (ocv_download)
cmake/OpenCVFindLibsVideo.cmake:219 (include)
CMakeLists.txt:557 (include)
CMake Error at cmake/OpenCVUtils.cmake:1047 (message):
Failed to download opencv_ffmpeg.dll. Status=6;"Couldn't resolve host
name"
Call Stack (most recent call first):
3rdparty/ffmpeg/ffmpeg.cmake:10 (ocv_download)
cmake/OpenCVFindLibsVideo.cmake:219 (include)
CMakeLists.txt:557 (include)
按这个报错先去找到hash值为f081abd9d6ca7e425d340ce586f9c090的opencv_ffmpeg.dll了。
找到了,然后放于文件夹
F:/build-opencv3.2.0/opencv-3.2.0/3rdparty/ffmpeg/downloads/f081abd9d6ca7e425d340ce586f9c090/
下
继续configure…
又报错:
Downloading opencv_ffmpeg_64.dll...
CMake Error at cmake/OpenCVUtils.cmake:1043 (file):
file DOWNLOAD HASH mismatch
for file: [F:/build-opencv3.2.0/opencv-3.2.0/3rdparty/ffmpeg/downloads/a423363a6eb76d362ca6c406c96c8db6/opencv_ffmpeg_64.dll]
expected hash: [a423363a6eb76d362ca6c406c96c8db6]
actual hash: [d41d8cd98f00b204e9800998ecf8427e]
status: [6;"Couldn't resolve host name"]
Call Stack (most recent call first):
3rdparty/ffmpeg/ffmpeg.cmake:15 (ocv_download)
cmake/OpenCVFindLibsVideo.cmake:219 (include)
CMakeLists.txt:557 (include)
CMake Error at cmake/OpenCVUtils.cmake:1047 (message):
Failed to download opencv_ffmpeg_64.dll. Status=6;"Couldn't resolve host
name"
Call Stack (most recent call first):
3rdparty/ffmpeg/ffmpeg.cmake:15 (ocv_download)
cmake/OpenCVFindLibsVideo.cmake:219 (include)
CMakeLists.txt:557 (include)
可见,缺少hash值为a423363a6eb76d362ca6c406c96c8db6的文件opencv_ffmpeg_64.dll,又去找…
找到了,放置于路径F:/build-opencv3.2.0/opencv-3.2.0/3rdparty/ffmpeg/downloads/a423363a6eb76d362ca6c406c96c8db6/下,
继续配置…
Downloading ffmpeg_version.cmake...
CMake Error at cmake/OpenCVUtils.cmake:1043 (file):
file DOWNLOAD HASH mismatch
for file: [F:/build-opencv3.2.0/opencv-3.2.0/3rdparty/ffmpeg/downloads/5346ae1854fc7aa569a722e85af480ec/ffmpeg_version.cmake]
expected hash: [5346ae1854fc7aa569a722e85af480ec]
actual hash: [d41d8cd98f00b204e9800998ecf8427e]
status: [6;"Couldn't resolve host name"]
Call Stack (most recent call first):
3rdparty/ffmpeg/ffmpeg.cmake:20 (ocv_download)
cmake/OpenCVFindLibsVideo.cmake:219 (include)
CMakeLists.txt:557 (include)
CMake Error at cmake/OpenCVUtils.cmake:1047 (message):
Failed to download ffmpeg_version.cmake. Status=6;"Couldn't resolve host
name"
Call Stack (most recent call first):
3rdparty/ffmpeg/ffmpeg.cmake:20 (ocv_download)
cmake/OpenCVFindLibsVideo.cmake:219 (include)
CMakeLists.txt:557 (include)
可见是缺少hash值为5346ae1854fc7aa569a722e85af480ec的文件ffmpeg_version.cmake,又去找…
找到了,放到路径F:/build-opencv3.2.0/opencv-3.2.0/3rdparty/ffmpeg/downloads/5346ae1854fc7aa569a722e85af480ec/下,
继续configure…
又报错…
ICV: Downloading ippicv_windows_20151201.zip...
CMake Error at 3rdparty/ippicv/downloader.cmake:73 (file):
file DOWNLOAD HASH mismatch
for file: [F:/build-opencv3.2.0/opencv-3.2.0/3rdparty/ippicv/downloads/windows-04e81ce5d0e329c3fbc606ae32cad44d/ippicv_windows_20151201.zip]
expected hash: [04e81ce5d0e329c3fbc606ae32cad44d]
actual hash: [d41d8cd98f00b204e9800998ecf8427e]
status: [6;"Couldn't resolve host name"]
Call Stack (most recent call first):
3rdparty/ippicv/downloader.cmake:110 (_icv_downloader)
cmake/OpenCVFindIPP.cmake:243 (include)
cmake/OpenCVFindLibsPerf.cmake:37 (include)
CMakeLists.txt:558 (include)
CMake Error at 3rdparty/ippicv/downloader.cmake:77 (message):
ICV: Failed to download ICV package: ippicv_windows_20151201.zip.
Status=6;"Couldn't resolve host name"
Call Stack (most recent call first):
3rdparty/ippicv/downloader.cmake:110 (_icv_downloader)
cmake/OpenCVFindIPP.cmake:243 (include)
cmake/OpenCVFindLibsPerf.cmake:37 (include)
CMakeLists.txt:558 (include)
可见缺少hash值为04e81ce5d0e329c3fbc606ae32cad44d的文件ippicv_windows_20151201.zip,
又去找…
找到了…放在路径F:/build-opencv3.2.0/opencv-3.2.0/3rdparty/ippicv/downloads/windows-04e81ce5d0e329c3fbc606ae32cad44d/下,
继续configure…
这下没问题了…
接下来把扩展库路径加入…
F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules
然后Generate…
Generate过程中报错…
错误日志如下:
CMake Error at cmake/OpenCVUtils.cmake:1043 (file):
file DOWNLOAD HASH mismatch
for file: [F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/cmake/.download/e8d0dcd54d1bcfdc29203d011a797179/vgg_generated_48.i]
expected hash: [e8d0dcd54d1bcfdc29203d011a797179]
actual hash: [d41d8cd98f00b204e9800998ecf8427e]
status: [6;"Couldn't resolve host name"]
Call Stack (most recent call first):
F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/cmake/download_vgg.cmake:13 (ocv_download)
F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/cmake/download_vgg.cmake:20 (vgg_download)
F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/CMakeLists.txt:4 (include)
CMake Error at cmake/OpenCVUtils.cmake:1047 (message):
Failed to download vgg_generated_48.i. Status=6;"Couldn't resolve host
name"
Call Stack (most recent call first):
F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/cmake/download_vgg.cmake:13 (ocv_download)
F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/cmake/download_vgg.cmake:20 (vgg_download)
F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/CMakeLists.txt:4 (include)
可见是缺少hash值为e8d0dcd54d1bcfdc29203d011a797179的文件vgg_generated_48.i
又去找文件vgg_generated_48.i
找到了…放入路径F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/cmake/.download/e8d0dcd54d1bcfdc29203d011a797179/
继续Generate…
继续报错…
Make Error at cmake/OpenCVUtils.cmake:1043 (file):
file DOWNLOAD HASH mismatch
for file: [F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/cmake/.download/7126a5d9a8884ebca5aea5d63d677225/vgg_generated_64.i]
expected hash: [7126a5d9a8884ebca5aea5d63d677225]
actual hash: [d41d8cd98f00b204e9800998ecf8427e]
status: [6;"Couldn't resolve host name"]
Call Stack (most recent call first):
F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/cmake/download_vgg.cmake:13 (ocv_download)
F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/cmake/download_vgg.cmake:21 (vgg_download)
F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/CMakeLists.txt:4 (include)
CMake Error at cmake/OpenCVUtils.cmake:1047 (message):
Failed to download vgg_generated_64.i. Status=6;"Couldn't resolve host
name"
Call Stack (most recent call first):
F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/cmake/download_vgg.cmake:13 (ocv_download)
F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/cmake/download_vgg.cmake:21 (vgg_download)
F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/CMakeLists.txt:4 (include)
又去找hash值为7126a5d9a8884ebca5aea5d63d677225的文件vgg_generated_64.i,
找到了,放于F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/cmake/.download/7126a5d9a8884ebca5aea5d63d677225/下
继续Generate…
但是我找到的Hash值不对…
Downloading vgg_generated_64.i...
CMake Error at cmake/OpenCVUtils.cmake:1043 (file):
file DOWNLOAD HASH mismatch
for file: [F:/build-opencv3.2.0/opencv_contrib-3.2.0/modules/xfeatures2d/cmake/.download/7126a5d9a8884ebca5aea5d63d677225/vgg_generated_64.i]
expected hash: [7126a5d9a8884ebca5aea5d63d677225]
actual hash: [d41d8cd98f00b204e9800998ecf8427e]
status: [6;"Couldn't resolve host name"]
服了…就弄到这里,换成OpenCV-3.1.0试下吧~
刚才我找到的几个文件的打包下载链接如下(除了最后一个 vgg_generated_64.i):
链接:https://pan.baidu.com/s/1jdCuhLzxS49TaZZIMEnjhg?pwd=lu75
以上是关于CMake编译OpenCV-3.2.0源码,使其可以在VS2013下进行图像处理开发的失败过程记录的主要内容,如果未能解决你的问题,请参考以下文章
在 Linux 下用 CMAKE 编译安装 OpenCV 3.2.0