Makefile:2: *** missing separator. Stop

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 !!

95300 次浏览

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