【发布时间】:2020-08-12 15:40:32
【问题描述】:
我正在关注“Learn C the Hard Way”一书,并且已经到了使用 makefile 编译代码的部分。在运行 make clean 时,我不断收到文件未找到的错误。 这是make文件和目录后跟的错误
C:\Users\Me\Desktop\C Code\HARD WAY\Dust off that compiler>make clean
rm -f main.c
process_begin: CreateProcess(NULL, rm -f main.c, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [makefile:7: clean] Error 2
EXECUTABLE=main.exe
CC="C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\gcc.exe"
CFLAGS=-Wall -g
clean:
rm -f main
编辑:我从“rm -f main”中删除了 .c,因为它似乎是一个小错误,但对最终结果没有影响
编辑 2:我发现 make 文件正在发出 linux 命令,这就是它不起作用的原因,用 del 替换 rm 解决了这个问题
【问题讨论】:
-
运行
make clean时为什么要删除C源文件?通常,clean目标用于删除输出文件。 -
不知道为什么,书上没有解释那部分
-
可能找不到'rm'?
-
如果在命令提示符下输入
rm(不带参数)会发生什么? -
感谢您的帮助,这些是 linux 命令而不是 windows,所以它不会工作