makefile:4: *** 缺少分隔符。停止。
makefile:4: *** 缺少分隔符。停止。
这是我的Makefile:
all:ll ll:ll.c gcc -c -Wall -Werror -02 c.c ll.c -o ll $@ $< clean : \rm -fr ll
当我尝试执行make clean
或make make
时,我遇到了这个错误:
:makefile:4: *** missing separator. Stop.
我该怎么解决它?
admin 更改状态以发布 2023年5月21日
make定义了每个食谱必须以制表符开始,每个规则的所有操作都由制表符标识。如果您喜欢在食谱前面加上不同于制表符的字符,您可以将.RECIPEPREFIX变量设置为替代字符。
要检查,我使用命令cat -e -t -v makefile_name
。
它显示了带有^I
的制表符和以$
结束的行。两者都是必不可少的,以确保依赖项正确结束,制表符标记规则的操作,使它们易于识别为make实用程序。
例如:
Kaizen ~/so_test $ cat -e -t -v mk.t all:ll$ ## here the $ is end of line ... $ ll:ll.c $ ^Igcc -c -Wall -Werror -02 c.c ll.c -o ll $@ $<$ ## the ^I above means a tab was there before the action part, so this line is ok . $ clean :$ \rm -fr ll$ ## see here there is no ^I which means , tab is not present .... ## in this case you need to open the file again and edit/ensure a tab ## starts the action part