MinGW 抛出 "The system cannot find the path specified." 错误
MinGW Make throwing "The system cannot find the path specified." error
我正在尝试在 Windows 7 上使用 cmake 生成一个 c++ 项目。在它实际创建项目之前,尽管看起来 cmake 对您的工具链进行了快速测试(我正在使用 MinGW),这就是我的问题在哪里。 Cmake 触发 make 构建,最终失败并返回 "The system cannot find the path specified."
我 运行 在干 运行 模式 (-n) 中失败的特定 makefile 并手动执行了所有命令:
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_report C:\SFML\CMakeFiles\CMakeTmp\CMakeFiles 1
echo Building C object CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj
C:\PROGRA~2\CODEBL~1\MinGW\bin\gcc.exe -o CMakeFiles\cmTryCompileExec306416588.dir\testCCompiler.c.obj -c C:\SFML\CMakeFiles\ CMakeTmp\testCCompiler.c
echo Linking C executable cmTryCompileExec306416588.exe
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTryCompileExec306416588.dir\link.txt --verbose=1
而且它们都执行无误,给我留下了预期的功能性 .exe 文件。然而,当 运行 通过 make I return 错误时:
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_report C:\SFML\CMakeFiles\CMakeTmp\CMakeFiles 1
The system cannot find the path specified.
mingw32-make.exe: *** [CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj] Error 1
然后我尝试用 "dir" 之类的简单命令替换所有命令,并注意到当 运行 通过 make 被 returned "The system cannort find the path specified" 打印出来之前目录信息并因错误退出。
我的下一步,据我所知,是 运行 使用 -d 标志;有趣的是:
Creating temporary batch file C:\Users\CJ\AppData\Local\Temp\make8664-1.bat
Batch file contents:
@echo off
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_report C:\SFML\CMakeFiles\CMakeTmp\CMakeFiles 1
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_report C:\SFML\CMakeFiles\CMakeTmp\CMakeFiles 1
CreateProcess(C:\Users\CJ\AppData\Local\Temp\make8664 1.bat,C:\Users\CJ\AppData\Local\Temp\make8664-1.bat,...)
Putting child 00490378 (CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj) PID 4730176 on the chain.
Live child 00490378 (CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj) PID 4730176
Main thread handle = 00000074
The system cannot find the path specified.
Reaping losing child 00490378 PID 4730176
Cleaning up temp batch file C:\Users\CJ\AppData\Local\Temp\make8664-1.bat
mingw32-make.exe: *** [CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj] Error 1
我不太了解 make 的内部工作原理,但从我从这个输出中可以看出,它似乎与 make 正在制作的临时批处理文件有关。我查看了这个 Whosebug post What causes GNU Make to shell out 看起来触发创建临时文件的内容非常模糊。我能够找到一个在没有创建临时批处理文件的情况下执行的命令("ls" 来自 windows Git bin)并且果然它通过 make 执行而没有 return像 "dir" 命令那样处理 "The system cannot find the path specified" 响应("dir" 导致 make 生成该临时文件)。
我觉得我的调试能力有点碰壁了,我向你们求助,看看你们是否可以提供任何建议。看起来我做出了正确的假设吗?您对问题的表现有什么见解吗?
看来我能够自己解决问题,很抱歉打扰 post。事实证明,问题不在于 Make,而在于 cmd 本身(每当 make 尝试 运行 批处理文件时,这将解释错误)。它看起来像某种方式(可能是通过某种潜入我的系统的恶意软件,或者可能是某种误导的 windows 更新)命令处理器的注册表项被设置为类似 "C:\Users\CJ\AppData\Roaming\Microsoft\Windows\IEUpdate\RMActivate_ssp.exe" 的东西,我记得专门从我的电脑不久前,因此每当 make 生成 cmd 进程时都会显示 "The system cannot find the path specified." 消息(我想我在打开根 cmd 进程时完全错过了它)。无论如何,这是按照 https://superuser.com/questions/727316/error-in-command-line-the-system-cannot-find-the-path-specified 中的说明进行的简单修复,之后我能够 运行 make 和随后的 cmake 构建,没有任何问题。
有问题的键是
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
and/or HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
如果您在 Cmake 中选择了 MSYS 工具集,但 运行在正常 shell 下使用它,也会发生此错误。在这种情况下,make
尝试编译类似于 /c/source/build/stuff.cpp
的东西,而正常的 Windows ABI 拒绝此路径。
此问题的一个很好的诊断方法是 Cmake 的 --debug-trycompile
标志。如果出现问题,您可以手动重新运行 失败的命令或查看生成的文件以查找原因。
我正在尝试在 Windows 7 上使用 cmake 生成一个 c++ 项目。在它实际创建项目之前,尽管看起来 cmake 对您的工具链进行了快速测试(我正在使用 MinGW),这就是我的问题在哪里。 Cmake 触发 make 构建,最终失败并返回 "The system cannot find the path specified."
我 运行 在干 运行 模式 (-n) 中失败的特定 makefile 并手动执行了所有命令:
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_report C:\SFML\CMakeFiles\CMakeTmp\CMakeFiles 1
echo Building C object CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj
C:\PROGRA~2\CODEBL~1\MinGW\bin\gcc.exe -o CMakeFiles\cmTryCompileExec306416588.dir\testCCompiler.c.obj -c C:\SFML\CMakeFiles\ CMakeTmp\testCCompiler.c
echo Linking C executable cmTryCompileExec306416588.exe
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTryCompileExec306416588.dir\link.txt --verbose=1
而且它们都执行无误,给我留下了预期的功能性 .exe 文件。然而,当 运行 通过 make I return 错误时:
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_report C:\SFML\CMakeFiles\CMakeTmp\CMakeFiles 1
The system cannot find the path specified.
mingw32-make.exe: *** [CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj] Error 1
然后我尝试用 "dir" 之类的简单命令替换所有命令,并注意到当 运行 通过 make 被 returned "The system cannort find the path specified" 打印出来之前目录信息并因错误退出。
我的下一步,据我所知,是 运行 使用 -d 标志;有趣的是:
Creating temporary batch file C:\Users\CJ\AppData\Local\Temp\make8664-1.bat
Batch file contents:
@echo off
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_report C:\SFML\CMakeFiles\CMakeTmp\CMakeFiles 1
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_report C:\SFML\CMakeFiles\CMakeTmp\CMakeFiles 1
CreateProcess(C:\Users\CJ\AppData\Local\Temp\make8664 1.bat,C:\Users\CJ\AppData\Local\Temp\make8664-1.bat,...)
Putting child 00490378 (CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj) PID 4730176 on the chain.
Live child 00490378 (CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj) PID 4730176
Main thread handle = 00000074
The system cannot find the path specified.
Reaping losing child 00490378 PID 4730176
Cleaning up temp batch file C:\Users\CJ\AppData\Local\Temp\make8664-1.bat
mingw32-make.exe: *** [CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj] Error 1
我不太了解 make 的内部工作原理,但从我从这个输出中可以看出,它似乎与 make 正在制作的临时批处理文件有关。我查看了这个 Whosebug post What causes GNU Make to shell out 看起来触发创建临时文件的内容非常模糊。我能够找到一个在没有创建临时批处理文件的情况下执行的命令("ls" 来自 windows Git bin)并且果然它通过 make 执行而没有 return像 "dir" 命令那样处理 "The system cannot find the path specified" 响应("dir" 导致 make 生成该临时文件)。
我觉得我的调试能力有点碰壁了,我向你们求助,看看你们是否可以提供任何建议。看起来我做出了正确的假设吗?您对问题的表现有什么见解吗?
看来我能够自己解决问题,很抱歉打扰 post。事实证明,问题不在于 Make,而在于 cmd 本身(每当 make 尝试 运行 批处理文件时,这将解释错误)。它看起来像某种方式(可能是通过某种潜入我的系统的恶意软件,或者可能是某种误导的 windows 更新)命令处理器的注册表项被设置为类似 "C:\Users\CJ\AppData\Roaming\Microsoft\Windows\IEUpdate\RMActivate_ssp.exe" 的东西,我记得专门从我的电脑不久前,因此每当 make 生成 cmd 进程时都会显示 "The system cannot find the path specified." 消息(我想我在打开根 cmd 进程时完全错过了它)。无论如何,这是按照 https://superuser.com/questions/727316/error-in-command-line-the-system-cannot-find-the-path-specified 中的说明进行的简单修复,之后我能够 运行 make 和随后的 cmake 构建,没有任何问题。
有问题的键是
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
and/or HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
如果您在 Cmake 中选择了 MSYS 工具集,但 运行在正常 shell 下使用它,也会发生此错误。在这种情况下,make
尝试编译类似于 /c/source/build/stuff.cpp
的东西,而正常的 Windows ABI 拒绝此路径。
此问题的一个很好的诊断方法是 Cmake 的 --debug-trycompile
标志。如果出现问题,您可以手动重新运行 失败的命令或查看生成的文件以查找原因。