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

我一直在尝试在opencv_contrib中安装附加模块,但是在尝试在CMake中配置时我一直遇到错误.

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

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

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作为管理员运行,但这并没有解决问题.

最佳答案 我设法让它工作,我想我会在这里更新以防其他人有类似的问题.

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

点赞