EK.
EK.

Reputation: 2996

"commence before first target. Stop." error

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

How to solve this problem?

Upvotes: 71

Views: 175244

Answers (7)

nav
nav

Reputation: 440

This could be echoing outside the target, for instance

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

Upvotes: 10

Sravya
Sravya

Reputation: 761

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

Upvotes: 5

Wesley
Wesley

Reputation: 539

This could also caused by mismatching brace/parenthesis.

$(TARGET}:
    do_something

Just use parenthesises and you'll be fine.

Upvotes: 0

Siddharth Joshi
Siddharth Joshi

Reputation: 11

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

Upvotes: 1

Raghu
Raghu

Reputation: 211

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.

Upvotes: 21

chacham15
chacham15

Reputation: 14251

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.

Upvotes: 60

Paul R
Paul R

Reputation: 212969

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.

Upvotes: 76

Related Questions