Makefile-缺少分隔符 [英] Makefile - missing separator

查看:471
本文介绍了Makefile-缺少分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
出现错误:缺少分隔符

Possible Duplicate:
Make error: missing separator

将此代码保存在makefile中:

Have this code in makefile:

PROG = semsearch
all: $(PROG)
%: %.c
gcc -o $@ $< -lpthread

clean:
rm $(PROG)

和错误

missing separator. stop.

有人可以帮助我吗?

推荐答案

您需要在以gccrm开头的行之前添加一个硬标签.需要使用make规则中的命令以制表符开头(除非它们在同一行后跟分号). 结果应如下所示:

You need to precede the lines starting with gcc and rm with a hard tab. Commands in make rules are required to start with a tab (unless they follow a semicolon on the same line). The result should look like this:

PROG = semsearch
all: $(PROG)
%: %.c
        gcc -o $@ $< -lpthread

clean:
        rm $(PROG)

请注意,某些编辑器可能被配置为插入空格序列而不是硬制表符.如果这些行的开头有空格,您还将看到缺少分隔符"错误.如果您在插入硬标签时确实遇到问题,请使用分号方式:

Note that some editors may be configured to insert a sequence of spaces instead of a hard tab. If there are spaces at the start of these lines you'll also see the "missing separator" error. If you do have problems inserting hard tabs, use the semicolon way:

PROG = semsearch
all: $(PROG)
%: %.c ; gcc -o $@ $< -lpthread

clean: ; rm $(PROG)

这篇关于Makefile-缺少分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆