编译Opencv3.3.1遇到的编译器无法识别的警告的问题解除:

问题描述:


本文,就是在一个硬件的SDK中用到了opencv3.3.1的版本,在笔者目前的VS2019,CUDA11版本下编译的问题和解决。在做Cmake的configure的时候,Cmake报了一个找不到编译器版本的错误,

 编译Opencv3.3.1遇到的编译器无法识别的警告的问题解除:_第1张图片

Selecting windows SDK version 10.0.19041.0 to target Windows 10.0.19045Make Warning at cmake/OpenCVDetectCXXCompiler.cmake:120(message):OpencV does not recognize MSVC VERSION "1929".set OpenCV RUNTIMEcannotcall Stack (most recent call first):
cMakelists.txt:138 (include) 

 


问题根本原因:

opencv3.3.1的版本大约是在2017年,这时候VS2019还没有出来吧,对应的微软内部ID版本号,自然是没有出来,我们只要稍微改一下配置的Makefile就可以了:


解决办法:

在如下路径:找到编译器配置文件:

opencv331/opencv/cmake/OpenCVDetectCXXCompiler.cmake

 找到这段代码,

if(MSVC)
  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()
  if(MSVC_VERSION EQUAL 1400)
    set(OpenCV_RUNTIME vc8)
  elseif(MSVC_VERSION EQUAL 1500)
    set(OpenCV_RUNTIME vc9)
  elseif(MSVC_VERSION EQUAL 1600)
    set(OpenCV_RUNTIME vc10)
  elseif(MSVC_VERSION EQUAL 1700)
    set(OpenCV_RUNTIME vc11)
  elseif(MSVC_VERSION EQUAL 1800)
    set(OpenCV_RUNTIME vc12)
  elseif(MSVC_VERSION EQUAL 1900)
    set(OpenCV_RUNTIME vc14)
  elseif(MSVC_VERSION EQUAL 1910 OR MSVC_VERSION EQUAL 1911)
    set(OpenCV_RUNTIME vc15)
  elseif(MSVC_VERSION EQUAL 1921 OR MSVC_VERSION EQUAL 1929)
    set(OpenCV_RUNTIME vc16)
  else()
    message(WARNING "OpenCV does not recognize MSVC_VERSION \"${MSVC_VERSION}\". Cannot set OpenCV_RUNTIME")
  endif()
elseif(MINGW)
  set(OpenCV_RUNTIME mingw)

  if(MINGW64)
    set(OpenCV_ARCH x64)
  else()
    set(OpenCV_ARCH x86)
  endif()
endif()

修改成上述即可:

注意,我修改的部分为:
编译Opencv3.3.1遇到的编译器无法识别的警告的问题解除:_第2张图片

你可能感兴趣的:(机器视觉,开源工具,opencv)