我正在尝试在Windows 7上使用cmake生成一个c++项目。在实际创建项目之前,cmake会进行一次快速的工具链(我使用MinGW)测试,这就是我的问题所在。Cmake触发了一个构建操作,最终失败并报错"The system cannot find the path specified."。
我以干燥运行模式(-n)运行了特定的失败Makefile,并手动执行了所有命令:
他们都没有错误地执行,让我得到了一个预期的 .exe 文件。然而当我通过 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帖子What causes GNU Make to shell out,似乎触发生成临时文件的原因比较模糊。我找到了一个没有生成临时批处理文件的命令(Windows Git bin中的"ls"),确实通过make执行而没有像"dir"命令那样导致生成临时文件出现"The system cannot find the path specified"响应。
我觉得我的调试能力已经达到了极限,所以我转向你们寻求建议。我的假设是否正确?你们对问题可能的表现有什么见解?