"commence before first target. Stop." error
Asked Answered
O

7

69

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

How to solve this problem?

Oviparous answered 26/5, 2010 at 11:59 Comment(4)
How about posting the file contents?Inrush
What's a *.mak-file? Not even 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.Kreis
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.Genniegennifer
Possible duplicate of {Makefile Error} "commands commence before first target. Stop."Lithium
T
73

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.

Thirddegree answered 26/5, 2010 at 12:6 Comment(3)
I got a build error due to a tab space after my line..this helpedGalaxy
a line before the error line, I had a tab space alsoSneer
In my case I had an equal sign (=) in the file name of the source code. Once I replaced it by a dash (-) the makefile worked just fine.Fibroid
C
55

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.

Commingle answered 27/5, 2013 at 22:57 Comment(0)
G
21

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.

Gilgai answered 11/6, 2015 at 8:30 Comment(1)
In particular, you can't even have a line ending with whitespace after the backslash!Historicism
T
9

This could be echoing outside the target, for instance

# Variable 
BAR = 
ifeq ($(FOO), 1)
    @echo "FooBar"  <----- generate the error
    BAR += foobar
endif
 
# Targets
all: 
...
...
Tearing answered 3/2, 2022 at 18:32 Comment(0)
N
5

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

Natator answered 12/6, 2020 at 13:13 Comment(1)
This is the sneaky one that got me, since the error message points to the line that isn't actually the problemNonconcurrence
A
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

Antisocial answered 12/9, 2019 at 9:38 Comment(0)
L
0

This could also caused by mismatching brace/parenthesis.

$(TARGET}:
    do_something

Just use parenthesises and you'll be fine.

Leatherman answered 13/1, 2020 at 13:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.