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.
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 1Common 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
- Scroll up to the first
error:line - that is the real diagnostic (e.g. an undeclared identifier, a missing header). - Fix that specific compile/link error; the
Error 1resolves with it. - 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.
make -j1 main.o # serial, clean output
# or keep going to collect all errors
make -kHow to prevent it
- Treat
Error 1as a pointer - always read the diagnostic above it. - Use
make --output-sync=targetin parallel CI builds for readable logs. - Fail CI on the first error so the root cause is near the end of the log.