MSBuild: 'error MSB6006: "cmd.exe"退出代码 1.'
尝试使用 CMake 和 MSBuild 构建 TensorFlow 时在 Windows 10 上,运行 MSBuild 时出现以下错误:
When attempting to build TensorFlow with CMake and MSBuild on Windows 10, I get the following error when running MSBuild:
"C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_tutorials_example_trainer.vcxproj" (default target) (1) ->
"C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_gpu_kernels.vcxproj" (default target) (90) ->
(CustomBuild target) ->
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1. [C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_gpu_kernels.vcxproj]
351 Warning(s)
1 Error(s)
所以我只收到一条错误消息,这只是告诉我 cmd.exe 已关闭,错误代码表明存在问题,但没有说明问题是什么.那么我怎样才能找出导致这个问题的原因,以便我可以解决它?
So I only get one error message, and that just tells me that cmd.exe was closed with an error code indicating that there was a problem, but not what the problem was. So how can I find out what caused this problem so I can solve it?
这个错误经常发生,因为默认的 cmake 安装位置需要管理员权限(通常是 C:/Program Files/).
This error commonly happens because the default cmake install location requires admin privileges (normally C:/Program Files/).
有两种简单的方法可以解决这个问题:
There are two simple ways around this:
以管理员身份运行visual studio覆盖 CMAKE_INSTALL_PREFIX 变量以指向不需要管理员权限的地方就个人而言,我推荐第二个选项(配置 cmake 时,命令类似于:cmake . -DCMAKE_INSTALL_PREFIX=D:/Some/Path)
Run visual studio as Administrator Override the CMAKE_INSTALL_PREFIX variable to point somewhere not requiring admin privileges Personally, I'd recommend the second option (When configuring cmake, the command would be something like: cmake . -DCMAKE_INSTALL_PREFIX=D:/Some/Path)