Learn

Arduino "exit status 1": what it means and where the real error is

Beginner

Or see every lesson.

  • 455parts on the bench
  • 43boards running now
  • 1.00xreal time, on every board
Arduino Uno: read a knob, ready to breaklive0.000 s 0.00x
Click to open it in the editor
Turn the knob; the sketch prints its reading on the serial monitor in the editor. Open it, break a line, and press Run to read the build tab.

"exit status 1" is not an error message. It is the last line the Arduino IDE prints when a program it ran, the compiler or the uploader, stopped and reported a failure. Every failure ends with it, from a missing semicolon to a board that is not plugged in, which is why searching for it alone turns up a thousand different answers.

The real message is above it. This page shows where to find it, and the fix for the handful of messages behind most of them. The circuit above reads a knob on A0 and prints it; open it in the editor and break it on purpose to practice reading a build.

Where to look

In the Arduino IDE 1.8 the last lines are exit status 1 and Error compiling for board Arduino Uno., with whichever board you picked. The Arduino IDE 2 shows Compilation error: exit status 1 in a pop-up, or puts the first error’s text there instead. Either way, scroll the output up to the first line that contains error:. It starts with a file name and two numbers, as in sketch.ino:12:5: error:, which are the line and the column.

If the output is short and shows no error line, turn on File, Preferences, "Show verbose output during compilation" and build again. "Compiler warnings: All" in the same place shows the warnings too, which often point at the real bug in a sketch that compiles but misbehaves.

Mokxi has no exit status line. Its build tab lists the compiler’s own messages as lines you can click, each one jumping to its file, line and column, and every error is underlined on its line in the editor.

If it failed while compiling

A syntax or name error has a line number and is in your sketch. The two most common, "was not declared in this scope" and "expected ';' before", each have a page of their own, linked at the bottom of this one.

A missing library looks like LiquidCrystal_I2C.h: No such file or directory (clang: 'LiquidCrystal_I2C.h' file not found). The #include names a header the IDE cannot find, because the library is not installed or its name is spelled differently. Install it from Tools, Manage Libraries. In Mokxi the common libraries are already there under their usual names, and for others the build tab offers to install one from the same Arduino Library Manager.

A linker error has no line number. undefined reference to 'loop' (Mokxi: undefined symbol: loop()) means the sketch has no loop() at all, or it is spelled Loop. multiple definition of usually means two copies of a library, or a library’s .cpp file copied into the sketch folder. The IDE lists the libraries it used under "Multiple libraries were found", and that list is where to look.

Out of memory is the last kind. "Sketch too big" means the program does not fit in flash, and "Not enough memory" or data section exceeds available space in board means the global variables do not fit in an Uno’s 2 KB of RAM; Mokxi says global variables do not fit in the 2 KB SRAM. Text in Serial.print("...") is the usual culprit on an Uno. On a real Uno, wrapped as F("..."), it stays in flash and takes no RAM. Mokxi’s F() leaves the text in RAM, so in the simulator a PROGMEM table is the fix that shows; the low memory guide measures both.

The knob sketch, with its text in flash; break one thing at a time
const int KNOB = A0;

void setup() {
  Serial.begin(9600);
  Serial.println(F("Knob on A0"));
}

void loop() {
  int raw = analogRead(KNOB);
  Serial.print(F("A0 = "));
  Serial.println(raw);
  delay(200);
}

If it failed while uploading

When exit status 1 comes after the status says uploading, the sketch compiled and avrdude, the uploader, failed. The lines above it start with avrdude:. The common one is stk500_getsync(): not in sync, which means the board’s bootloader never answered, and its checklist starts with the port and, on a Nano clone, the Old Bootloader setting.

Practice on the sketch above: delete the semicolon after Serial.begin(9600), then spell KNOB as Knob, then delete the last closing brace, one at a time. Each gives a different first error, and in each case that first error is the one to read.

When you ask for help

If the first error still makes no sense, ask, but bring the right lines. A forum post that says only "exit status 1" cannot be answered, because it is the same line for every failure. Copy the first line that contains error: and the two or three lines under it, which show the code it points at, and say which board you selected and which version of the IDE you are using.

Then post the whole sketch, inside the forum’s code tags so that its quotes and brackets survive. Most mistakes sit a few lines above where they are reported, and the person helping you needs those lines too. If the sketch uses a library, name it and say where it came from, because several libraries share the same header name.

Questions

Is exit status 1 a compile error or an upload error?

Either. It only says the last program the IDE ran failed. If the lines above it start with a file name and "error:", the sketch did not compile; if they start with "avrdude:", the upload failed.

What does "Error compiling for board Arduino Uno" mean?

That the sketch did not compile for the board selected in Tools, Board. The reason is the first "error:" line above it. A sketch written for a different board, using Serial1 for example, can compile on that board and fail on an Uno.

How do I see the full error in the Arduino IDE?

Make the output panel taller, scroll up, and turn on File, Preferences, "Show verbose output during compilation". If you search for the error, copy the first error line, not the last line.

Does Mokxi show exit status 1?

No. Its build tab shows the compiler’s own messages, each one clickable to its line, and a failed upload says what went wrong in words. The messages are clang’s, so they are worded differently from the GCC messages the Arduino IDE shows.

Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.