66

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

How to solve this problem?

A-Sharabiani
  • 17,750
  • 17
  • 113
  • 128
EK.
  • 2,890
  • 9
  • 36
  • 49
  • 3
    How about posting the file contents? – Amir Rachum May 26 '10 at 12:02
  • 1
    What's a *.mak-file? Not even http://www.wotsit.org/list.asp?al=M mentions it. What are you trying to do? What exactly is this about? If this is about make, then which incarnation of it are you using? There are plenty of makes. – Sebastian Mach May 26 '10 at 12:02
  • 1
    The question does not appear to have anything to do with c or c++, so I edited the tags. I *could* do with and indication of just what build system you are using, however. Try `make --version` or check with the make manpage. – dmckee --- ex-moderator kitten May 26 '10 at 12:39
  • 1
    Possible duplicate of [{Makefile Error} "commands commence before first target. Stop."](http://stackoverflow.com/questions/21238223/makefile-error-commands-commence-before-first-target-stop) – tripleee Dec 18 '15 at 17:38

7 Answers7

68

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.

Paul R
  • 208,748
  • 37
  • 389
  • 560
52

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.

chacham15
  • 13,719
  • 26
  • 104
  • 207
20

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.

Raghu
  • 201
  • 2
  • 2
8

This could be echoing outside the target, for instance

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

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

Sravya
  • 661
  • 8
  • 9
1

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

Snoobie
  • 760
  • 2
  • 12
  • 30
0

This could also caused by mismatching brace/parenthesis.

$(TARGET}:
    do_something

Just use parenthesises and you'll be fine.

Wesley
  • 501
  • 7
  • 19