"commence before first target. Stop." error

Makefile

Makefile Problem Overview


In *.mak file I receive commands "commence before first target. Stop." I didn't change it before.

How to solve this problem?

Makefile Solutions


Solution 1 - Makefile

make (or NMAKE, or whatever flavour of make you are using) can be quite picky about the format of makefiles - check that you didn't actually edit the file in any way, e.g. changed line endings, spaces <-> tabs, etc.

Solution 2 - Makefile

This means that there is a line which starts with a space, tab, or some other whitespace without having a target in front of it.

Solution 3 - Makefile

if you have added a new line, Make sure you have added next line syntax in previous line. typically if "" is missing in your previous line of changes, you will get this error.

Solution 4 - Makefile

Also, make sure you dont have a space after \ in previous line Else this is the error

Solution 5 - Makefile

It's a simple Mistake while adding a new file you just have to make sure that \ is added to the file before and the new file remain as it is eg.

Check Out what to do if i want to add a new file named customer.cc

Solution 6 - Makefile

This could be echoing outside the target, for instance

# Variable 
BAR = 
ifeq ($(FOO), 1)
    @echo "FooBar"  <----- generate the error
	BAR += foobar
endif
 
# Targets
all: 
...
...

Solution 7 - Makefile

This could also caused by mismatching brace/parenthesis.

$(TARGET}:
	do_something

Just use parenthesises and you'll be fine.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEK.View Question on Stackoverflow
Solution 1 - MakefilePaul RView Answer on Stackoverflow
Solution 2 - Makefilechacham15View Answer on Stackoverflow
Solution 3 - MakefileRaghuView Answer on Stackoverflow
Solution 4 - MakefileSravyaView Answer on Stackoverflow
Solution 5 - MakefileSiddharth JoshiView Answer on Stackoverflow
Solution 6 - MakefileThiago NavarroView Answer on Stackoverflow
Solution 7 - MakefileWesleyView Answer on Stackoverflow