makefile:4: *** 缺少分隔符.停止 [英] makefile:4: *** missing separator. Stop
问题描述
这是我的生成文件:
all:ll
ll:ll.c
gcc -c -Wall -Werror -02 c.c ll.c -o ll $@ $<
clean :
m -fr ll
当我尝试 make clean
或 make make
时,我收到此错误:
When I try to make clean
or make make
, I get this error:
:makefile:4: *** missing separator. Stop.
我该如何解决?
推荐答案
make 与制表符的关系非常愚蠢.每个规则的所有操作都由选项卡标识.而且,不,四个空格不能构成一个制表符.只有标签才能成为标签.
make has a very stupid relationship with tabs. All actions of every rule are identified by tabs. And, no, four spaces don't make a tab. Only a tab makes a tab.
为了检查,我使用命令 cat -e -t -v makefile_name
.
To check, I use the command cat -e -t -v makefile_name
.
它显示了带有 ^I
的制表符和带有 $
的行结尾.两者对于确保依赖项正确结束都很重要,选项卡标记规则的操作,以便 make 实用程序可以轻松识别它们.
It shows the presence of tabs with ^I
and line endings with $
. Both are vital to ensure that dependencies end properly and tabs mark the action for the rules so that they are easily identifiable to the make utility.
示例:
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 :$
m -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
这篇关于makefile:4: *** 缺少分隔符.停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!