MinGW Make 抛出“系统找不到指定的路径。” 错误

Ssa*_*awa 5 windows mingw makefile cmake

我正在尝试在 Windows 7 上使用 cmake 生成一个 c++ 项目。在实际创建项目之前,cmake 会对您的工具链进行快速测试(我正在使用 MinGW),这就是我的问题所在。Cmake 触发 make 构建,最终失败并返回“系统找不到指定的路径”。

我运行了在试运行模式 (-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
Run Code Online (Sandbox Code Playgroud)

它们都没有错误地执行,让我得到了预期的功能性 .exe 文件。但是,当运行 make 时,我返回错误:

"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
Run Code Online (Sandbox Code Playgroud)

然后,我尝试用“dir”之类的简单命令替换所有命令,并注意到当运行 make 时,会再次返回“系统无法找到指定的路径”,然后打印出 dir 信息并错误退出。

我的下一步,据我所知,是使用 -d 标志运行 make ;有趣的是:

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
Run Code Online (Sandbox Code Playgroud)

我对 make 的内部工作原理不太了解,但从我从这个输出中可以看出,它看起来与 make 正在制作的临时批处理文件有关。我看了这篇 stackoverflow 帖子What Causes Causes GNU Make to shell out,看起来是什么触发了临时文件的创建,这非常模糊。我能够找到一个在没有创建临时批处理文件(来自 Windows Git bin 的“ls”)的情况下执行的命令,并且果然它通过 make 执行,而没有返回“系统找不到指定的路径”响应,例如“ dir”命令执行了(“dir”导致 make 生成该临时文件)。

我觉得我的调试能力有点碰壁了,我向你们求助,看看你们是否可以提供任何建议。我的假设看起来正确吗?您对可能出现的问题有什么见解吗?

Ssa*_*awa 4

看起来我能够自己解决这个问题,很抱歉打扰这个帖子。事实证明,问题不在于 Make,而在于 cmd 本身(每当 make 尝试运行批处理文件时,这都会解释错误)。看起来不知何故(可能是通过某种恶意软件潜入我的系统,或者可能是某种误导性的 Windows 更新)命令处理器的注册表项被设置为类似“C:\Users\CJ\AppData\Roaming\Microsoft\Windows” \IEUpdate\RMActivate_ssp.exe”,我记得不久前专门从我的计算机上删除了它,因此“系统找不到指定的路径”。每当 make 生成 cmd 进程时都会发出消息(我想当我打开根 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和/或HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun