我正在尝试在 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
它们都执行得没有错误,给我留下了一个符合预期的功能性 .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
然后,我尝试用“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
我对 make 的内部工作原理不太了解,但从我从这个输出中可以看出,它看起来与 make 正在制作的临时批处理文件有关。我看了这个 stackoverflow 帖子是什么导致 GNU Make 出壳 https://stackoverflow.com/questions/24506418/what-causes-gnu-make-to-shell-out看起来触发临时文件创建的原因非常模糊。我能够找到一个在没有创建临时批处理文件(来自 Windows Git bin 的“ls”)的情况下执行的命令,并且果然它通过 make 执行,而没有返回“系统找不到指定的路径”响应,例如“ dir”命令执行了(“dir”导致 make 生成该临时文件)。
我觉得我的调试能力有点碰壁了,我向你们求助,看看你们是否可以提供任何建议。我的假设看起来正确吗?您对可能出现的问题有什么见解吗?