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 !!
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With