Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Makefile - missing separator [duplicate]

Possible Duplicate:
Make error: missing separator

Have this code in makefile:

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

clean:
rm $(PROG)

and the error

missing separator. stop.

Can someone help me?

like image 295
user1827257 Avatar asked Jan 01 '13 10:01

user1827257


People also ask

What does missing separator in makefile?

Means that the makefile contains spaces instead of Tab's. The make utility is notoriously picky about the use of Space instead of Tab . So it's likely that the makefile contains Space at the beginning of rule stanzas within the file.

Are tabs or spaces used to indent the commands after the rule in a makefile?

Recipes in makefile rules must start with a tab (per definition). If a single tab (interpreted as 8 spaces wide) is not enough to put the recipe clearly indented (meaning at least 4 spaces difference) from the code around it, use additional tabs.


1 Answers

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)
like image 81
Jens Avatar answered Oct 27 '22 01:10

Jens