OpenCV在Windows上使用CMake安装opencv_contrib模块

时间:2016-11-18 13:38:28

标签: windows opencv cmake

我一直在尝试在opencv_contrib中安装其他模块,但在尝试在CMake中配置时,我一直遇到错误。

这是我到目前为止采取的步骤:

  1. 从github下载opencv和opencv_contrib。
  2. 将我想要的模块从opencv_contrib粘贴到opencv / modules。
  3. 在opencv中创建了一个构建文件夹, seen here.
  4. 在CMake gui中,我将源代码设置为C:/opencv-3.1.0-dev,并将build文件夹设置为C:/opencv-3.1.0-dev中包含的build文件夹。
  5. 按下配置后,我将项目的生成器设置为visual studio 15。
  6. 我将本机C和C ++编译器指定为:
  7.   

    C:/ Program Files(x86)/ Microsoft Visual Studio 14.0 / VC / bin / cl.exe

    当我确认这个并且配置进度时,我提供了这个错误:

    The CXX compiler identification is unknown
    The C compiler identification is unknown
    Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
    CMake Error: Generator: execution of make failed. Make command was: "MSBuild.exe" "cmTC_7c114.vcxproj" "/p:Configuration=Debug" "/p:VisualStudioVersion=15.0"
    Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- broken
    CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/CMakeTestCXXCompiler.cmake:44 (message):
      The C++ compiler "C:/Program Files (x86)/Microsoft Visual Studio
      14.0/VC/bin/cl.exe" is not able to compile a simple test program.
    
      It fails with the following output:
    
       Change Dir: C:/opencv-3.1.0-dev/build/CMakeFiles/CMakeTmp
    
      Run Build Command:"MSBuild.exe" "cmTC_7c114.vcxproj"
      "/p:Configuration=Debug" "/p:VisualStudioVersion=15.0"
    
    
      Generator: execution of make failed.  Make command was: "MSBuild.exe"
      "cmTC_7c114.vcxproj" "/p:Configuration=Debug" "/p:VisualStudioVersion=15.0"
    
    
      CMake will not be able to correctly generate this project.
    Call Stack (most recent call first):
      CMakeLists.txt:98 (project)
    
    
    Configuring incomplete, errors occurred!
    See also "C:/opencv-3.1.0-dev/build/CMakeFiles/CMakeOutput.log".
    See also "C:/opencv-3.1.0-dev/build/CMakeFiles/CMakeError.log".
    

    请有人解释如何解决这个问题,还是有其他方法可以包含我需要的模块?

    我环顾四周,建议将cl.exe作为管理员运行,但这并没有解决问题。

1 个答案:

答案 0 :(得分:2)

我设法让它工作,我想我会在这里更新以防其他人遇到类似的问题。

我不应该选择Visual Studio 15作为项目的生成器,而应该选择的实际生成器是Visual Studio 14 Win64。