C ++如何为vs 2015 x86构建opencv
Posted
技术标签:
【中文标题】C ++如何为vs 2015 x86构建opencv【英文标题】:C++ How can I build opencv for vs 2015 x86 【发布时间】:2017-10-17 12:57:17 【问题描述】:我想在我的 VS2015 C++ 项目中使用 opencv,我需要它来完全用于 x86 平台,而不是 x64。 我按照互联网上各处的建议使用了 CMake。更何况我尝试配置几个版本的opencv - 2.4.9; 3.0.0; 3.1.0 在每次通过 CMake 配置和生成时,我都会遇到很多错误。 这是配置后来自 CMake gui 的日志:
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.
The CXX compiler identification is MSVC 19.0.23506.0
The C compiler identification is MSVC 19.0.23506.0
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Performing Test HAVE_CXX_FSIGNED_CHAR
Performing Test HAVE_CXX_FSIGNED_CHAR - Failed
Performing Test HAVE_C_FSIGNED_CHAR
Performing Test HAVE_C_FSIGNED_CHAR - Failed
Check if the system is big endian
Searching 16 bit integer
Looking for sys/types.h
Looking for sys/types.h - found
Looking for stdint.h
Looking for stdint.h - found
Looking for stddef.h
Looking for stddef.h - found
Check size of unsigned short
Check size of unsigned short - done
Using unsigned short
Check if the system is big endian - little endian
Looking for fseeko
Looking for fseeko - not found
Looking for unistd.h
Looking for unistd.h - not found
Check size of off64_t
Check size of off64_t - failed
Looking for assert.h
Looking for assert.h - found
Looking for fcntl.h
Looking for fcntl.h - found
Looking for io.h
Looking for io.h - found
Looking for jbg_newlen
Looking for jbg_newlen - not found
Looking for mmap
Looking for mmap - not found
Looking for search.h
Looking for search.h - found
Looking for string.h
Looking for string.h - found
Looking for unistd.h
Looking for unistd.h - not found
CMake Warning at 3rdparty/ippicv/downloader.cmake:54 (message):
ICV: Local copy of ICV package has invalid MD5 hash:
d41d8cd98f00b204e9800998ecf8427e (expected:
b59f865d1ba16e8c84124e19d78eec57)
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)
ICV: Downloading ippicv_windows_20141027.zip...
CMake Error at 3rdparty/ippicv/downloader.cmake:71 (file):
file DOWNLOAD HASH mismatch
for file: [D:/opencv-3.0/opencv/sources/3rdparty/ippicv/downloads/windows-b59f865d1ba16e8c84124e19d78eec57/ippicv_windows_20141027.zip]
expected hash: [b59f865d1ba16e8c84124e19d78eec57]
actual hash: [d41d8cd98f00b204e9800998ecf8427e]
status: [6;"Couldn't resolve host name"]
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=6;"Couldn't resolve host name"
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)
Configuring incomplete, errors occurred!
See also "D:/opencv-build/CMakeFiles/CMakeOutput.log".
See also "D:/opencv-build/CMakeFiles/CMakeError.log".
而且这个日志是在生成之后的:
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 Warning at 3rdparty/ippicv/downloader.cmake:54 (message):
ICV: Local copy of ICV package has invalid MD5 hash:
d41d8cd98f00b204e9800998ecf8427e (expected:
b59f865d1ba16e8c84124e19d78eec57)
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)
ICV: Downloading ippicv_windows_20141027.zip...
CMake Error at 3rdparty/ippicv/downloader.cmake:71 (file):
file DOWNLOAD HASH mismatch
for file: [D:/opencv-3.0/opencv/sources/3rdparty/ippicv/downloads/windows-b59f865d1ba16e8c84124e19d78eec57/ippicv_windows_20141027.zip]
expected hash: [b59f865d1ba16e8c84124e19d78eec57]
actual hash: [d41d8cd98f00b204e9800998ecf8427e]
status: [6;"Couldn't resolve host name"]
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=6;"Couldn't resolve host name"
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)
Configuring incomplete, errors occurred!
See also "D:/opencv-build/CMakeFiles/CMakeOutput.log".
See also "D:/opencv-build/CMakeFiles/CMakeError.log".
CMakeOutput.log 和 CMakeError.log 都不可读。它们充满了不可读的字符。
我怎样才能得到这个vc14 x86版本的opencv!? 我被困住了。
【问题讨论】:
您似乎正在尝试从错误的 url 下载 ippicv_windows_20141027.zip。要么,要么下载已损坏。没有办法告诉你,因为你遗漏了 CMakeLists.txt 我在您的日志中看到的是“无法解析主机名”...您在进行 cmake 时是否有互联网? opencv 的 cmake 正在尝试下载一些缺失的模块,以使用它们。 khm.. 我在工作,我们在这里使用代理.. 也许这就是问题.. 好吧,我会尝试在家里构建 opencv。感谢您的想法。 您可以尝试手动下载吗?这是来自github of the file 的链接,只要把它放在它应该在的地方,也许它可以工作......但是,你也在使用一个相当旧的版本...... 2014!您应该尝试获取更新的资源:) 【参考方案1】:在 OpenCVConfig.cmake 中,
if(MSVC)
message("CMAKE_CL_64 is $CMAKE_CL_64")
if(CMAKE_CL_64)
set(OpenCV_ARCH x64)
elseif((CMAKE_GENERATOR MATCHES "ARM") OR ("$arch_hint" STREQUAL "ARM") OR (CMAKE_VS_EFFECTIVE_PLATFORMS MATCHES "ARM|arm"))
# see Modules/CmakeGenericSystem.cmake
set(OpenCV_ARCH ARM)
else()
set(OpenCV_ARCH x86)
endif()
【讨论】:
以上是关于C ++如何为vs 2015 x86构建opencv的主要内容,如果未能解决你的问题,请参考以下文章