C++ 如何构建 opencv 与 2015 x86

C++ How can I build opencv for vs 2015 x86

本文关键字:opencv 2015 x86 构建 何构建 C++      更新时间:2023-10-16

我想在我的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!?我被卡住了。

在 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()