"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?

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.

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.

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.

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

This could also caused by mismatching brace/parenthesis.

$(TARGET}:
    do_something

Just use parenthesises and you'll be fine.

Comments
  • How about posting the file contents?
  • 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.
  • 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.
  • Possible duplicate of {Makefile Error} "commands commence before first target. Stop."
  • I got a build error due to a tab space after my line..this helped
  • a line before the error line, I had a tab space also