CMake "failed to run MSBUILD.exe" 命令错误

CMake "failed to run MSBUILD.exe" command error

当我想为 opencv 3.3.0 创建 visual studio 15(2017) make 文件时,它给了我这个错误消息:error in configuration process, project files maybe invalid 和这些:

CMake Deprecation Warning at CMakeLists.txt:81 (cmake_policy):
  The OLD behavior for policy CMP0020 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:85 (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:94 (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 Error at CMakeLists.txt:127 (project):
  Failed to run MSBuild command:

    MSBuild.exe

  to get the value of VCTargetsPath:

我使用 windows 10. 问题是什么,我该如何解决?

尝试安装 Windows SDK (Windows 10 SDK) 和 运行 具有 管理员权限的 CMake. 如果这没有帮助,请使用完整的警告和错误消息编辑您的问题,因为您已经跳过了最重要的部分。

在 CMake-gui 中:select编辑源代码和二进制文件夹并单击 "configure" 后,它会询问您使用哪个版本的编译器。确保你 select 是正确的

例如,如果您安装了 "Visual Studio 2015" 并且您 select "Visual Studio 2017",您将 运行 进入 "Failed to run MSBuild command:" 错误。

如果您 select 做错了,请删除二进制文件文件夹或简单地使用另一个二进制文件文件夹 - 然后单击配置并 select 正确的编译器。

每当 cmake 找不到 Visual Studio 组件时,这是因为 cmake 使用的构建选项指定了您尚未安装的版本。因此,要么更改 cmake 选项,要么安装所需的 Visual Studio 版本(14.0=2015、15.0=2017、16.0=2019)和所需的组件(通常是 Visual C++ 组件和 Windows SDK组件)。