When you verify or upload a sketch, the error Compilation error: exit status 1
may appear in the console and in a pop-up notification.
Note: For other compilation errors, see If your sketch doesn’t compile.
Quick checks
-
Make sure you have the right board selected in the board selector or the Tools > Board menu. See Select board and port in Arduino IDE for more information.
-
Make sure you’ve declared
setup()
andvoid()
functions in your sketch, even if they’re not being used:void setup() { // put your setup code here, to run once: } void loop() { // put your main code here, to run repeatedly: }
-
Check for missing, outdated, or conflicting libraries in the console output.
Check the console output for more information
To get more information about the error, we need to check the console output:
-
If a pop-up notification is still showing, close it by clicking the x in the top-right corner.
-
Find the console output panel.
-
Read the first few lines. Often, a
Compilation error: exit status 1
error message will be preceded by other, similar sounding messages such as:collect2: error: ld returned 1 exit status
exit status 1
Since these are also generic error messages, continue reading.
-
Look for lines starting with file paths. At this point, you may need to resize the window or scroll to the right to reveal the full lines. These files will often be pointing at
main.cpp
function, or a temporary copy of your sketch. -
In this example, the message
…main.ccp:43: undefined reference to `setup’
is the most informative:In this case, the error was caused by a missing
setup()
function.
If you still need help
-
Arduino sketches are written in the Arduino language, which is based on standard C++ language. Most likely you will find a wealth of resources by searching
C++ <error message>
in your search engine. -
For help with functions specific to Arduino, see the Arduino functions reference.
-
Visit the Programming Questions category in the Arduino forum. Start by reading the pinned threads which will contain useful information on how to best post a question.