【发布时间】:2015-06-09 15:04:03
【问题描述】:
我正在尝试在 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 帖子What causes GNU Make to shell out,看起来触发临时文件的原因非常模糊。我能够找到一个在没有创建临时批处理文件(Windows Git bin 中的“ls”)的情况下执行的命令,并且确实它通过 make 执行而没有返回“系统找不到指定的路径”响应,如“ dir" 命令执行("dir" 导致 make 生成该临时文件)。
我觉得我的调试能力有点碰壁了,我想向你们求助,看看你们能否提供任何建议。看起来我做出了正确的假设吗?您对可能出现的问题有任何见解吗?
【问题讨论】:
-
我曾经遇到过类似的问题,原因是我的杀毒软件,你可以看看要不要暂时禁用它。
-
@Antonio:我也遇到了同样的问题——见this question and answer。
标签: windows cmake makefile mingw