Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Makefile:2: *** missing separator. Stop [duplicate]

Tags:

makefile

I have two .cpp files namely decryptor.cpp and prod-ent.cpp.
I have created a Makefile to for the compilation of both the files in Linux platform.

all: decryptor.cpp prod-ent.cpp        g++ prod-ent.cpp -o prod-ent -g        g++ decryptor.cpp -o decryptor -g -lcryptopp clean:        rm prod-ent        rm decryptor 

Whenever I'm trying to execute the Makefile its showing me the following error:

Makefile:2: * missing separator. Stop.

I am new to create makefiles and cannot figure out my fault. Please help me in correcting the code.

Thanks in advance !!

like image 756
user3686363 Avatar asked May 29 '14 06:05

user3686363


People also ask

What is 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.

What does $() mean in makefile?

The $@ and $< are called automatic variables. The variable $@ represents the name of the target and $< represents the first prerequisite required to create the output file.

Do makefiles need tabs?

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.

How do I run a makefile in Linux?

Also you can just type make if your file name is makefile/Makefile . Suppose you have two files named makefile and Makefile in the same directory then makefile is executed if make alone is given. You can even pass arguments to makefile.


1 Answers

You need a real tab instead of space in front of g++ and rm commands. If still fails then your editor is inserting spaces instead, even if you're hitting the tab key on your keyboard. You need to configure your editor to insert hard tabs (09 in ASCII) instead.

Like

all: decryptor.cpp prod-ent.cpp *****g++ prod-ent.cpp -o prod-ent -g *****g++ decryptor.cpp -o decryptor -g -lcryptopp clean: *****rm prod-ent *****rm decryptor 

Instead ***** replace TAB.

You can check your side by command

cat -e -t -v  makefile 

It's show line starting by ^I if TAB is given to that line and it end the line by $.

Also you can do by ;

all: decryptor.cpp prod-ent.cpp ; g++ prod-ent.cpp -o prod-ent -g ; g++ decryptor.cpp -o decryptor -g -lcryptopp clean: ; rm prod-ent ; rm decryptor 
like image 183
Jayesh Bhoi Avatar answered Nov 10 '22 06:11

Jayesh Bhoi