Skip to content
Latchkey

Make "*** [target] Error 1" - A Build Command Failed

This line is not the error - it is make reporting that a command in a recipe exited with a non-zero status. The actual failure (a compiler or linker error) is printed in the lines just above it.

What this error means

The build ends with make: *** [Makefile:42: app] Error 1. The number after "Error" is the exit code of the failed command. The diagnostic that matters is above this line.

make output
g++ -c -o main.o main.cpp
main.cpp:7:5: error: 'cout' was not declared in this scope
make: *** [Makefile:42: main.o] Error 1

Common causes

A recipe command exited non-zero

make runs each recipe line in a shell; if any returns non-zero (a compile error, a missing tool, a failed test), make aborts the target and prints Error <code>.

Reading the summary line instead of the real error

The Error 1 line is a consequence. Scrolling up to the first compiler/linker diagnostic is what reveals the root cause.

How to fix it

Read the failure above the Error line

  1. Scroll up to the first error: line - that is the real diagnostic (e.g. an undeclared identifier, a missing header).
  2. Fix that specific compile/link error; the Error 1 resolves with it.
  3. Run the failed compiler command directly to iterate faster.

Surface failures clearly in parallel builds

With -j, output interleaves. Re-run the failing target serially (or with output sync) to read the diagnostic cleanly.

Terminal
make -j1 main.o          # serial, clean output
# or keep going to collect all errors
make -k

How to prevent it

  • Treat Error 1 as a pointer - always read the diagnostic above it.
  • Use make --output-sync=target in parallel CI builds for readable logs.
  • Fail CI on the first error so the root cause is near the end of the log.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →