这是我的makefile:
all:ll
ll:ll.c
gcc -c -Wall -Werror -02 c.c ll.c -o ll $@ $<
clean :
\rm -fr ll
Run Code Online (Sandbox Code Playgroud)
当我尝试make clean或make make,我得到这个错误:
:makefile:4: *** missing separator. Stop.
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
nit*_*tin 844
makefile与制表符有非常愚蠢的关系,每个规则的所有操作都由制表符标识......而No 4空格不制作制表符,只有制表符制作标签...
检查我使用命令 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
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助 !!
Den*_*hew 26
你应该总是在"tab"之后写命令而不是空格.
这适用于您的情况下的"gcc"行(第4行).你需要在gcc之前插入标签.
同样用"rm -fr ll"替换\ rm -fr ll.也可以在此命令之前插入标签
ala*_*wsx 24
在VS Code上,只需单击右下角的"Space:4",然后在编辑Makefile时将其更改为tab.
Dan*_* W. 10
使用.editorconfig,自动将修复标签:
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
[Makefile]
indent_style = tab
Run Code Online (Sandbox Code Playgroud)
解决方案PyCharm是安装Makefile support插件:
Preferences(cmd + ,)Plugins->MarketplaceMakefile support,安装并重新启动IDE。这应该可以解决问题,并提供Makefile的语法。
这是一个非常古老的问题,但我仍然想说一下使用vi/vim编辑器可视化选项卡的另一个选项.如果已vi/vim安装,则打开Makefile(例如vim Makefile)并输入:set list.这将显示如下插入的标签数量,
%-linux: force$
^I@if [ "$(GCC_VERSION)" = "2.96" ] ; then \$
^I^Iecho ===== Generating build tree for legacy $@ architecture =====; \$
^I^I$(CONFIGURE) $(CWD) $@ legacy; \$
^Ielse \$
^I^Iecho ===== Generating build tree for $@ architecture =====; \$
^I^I$(CONFIGURE) $(CWD) $@; \$
^Ifi$
^Icd build-$@;make$
Run Code Online (Sandbox Code Playgroud)
如果您希望将一行代码解释为make只能用空格缩进的代码,makefile 语法可能很奇怪。
如果您希望将一行代码解释为bash代码,则只能使用制表符缩进
sometask:
ifeq($FOO,bar) // this is make code. only spaces
echo "foobar" // this is bash code. only tabs
endif // again, this is make code. only spaces
Run Code Online (Sandbox Code Playgroud)
从技术上讲,它是决定解释器的主要缩进。
| 归档时间: |
|
| 查看次数: |
410098 次 |
| 最近记录: |