Skip to content

Commit b166534

Browse files
committed
Update If-your-sketch-doesnt-compile.md
1 parent 24b0bca commit b166534

File tree

1 file changed

+37
-24
lines changed

1 file changed

+37
-24
lines changed

content/Software Support/Compilation/If-your-sketch-doesnt-compile.md

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@ id: 4402764401554
55

66
Learn about compilation errors in your sketch and how to resolve them.
77

8+
In this article:
9+
10+
* [Quick checks](#quick-checks)
11+
* [How to interpret an error message](#how-to-interpret-an-error-message)
12+
* [Troubleshoot a specific error](#troubleshoot-a-specific-error)
13+
814
---
915

16+
<a id="quick-checks"></a>
17+
1018
## Quick checks
1119

1220
* Make sure your error occurs during compilation by clicking ![Verify button](img/symbol_verify2.png) **Verify** instead of ![Upload button](img/symbol_upload2.png) **Upload**. This will compile the sketch without attempting to upload it. If your error only occurs when uploading, see [Errors when uploading a sketch](https://support.arduino.cc/hc/en-us/articles/4403365313810-Errors-when-uploading-a-sketch).
1321

22+
* 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](https://support.arduino.cc/hc/en-us/articles/4406856349970-Select-board-and-port-in-Arduino-IDE) for more information.
23+
1424
* A successful compilation will always finish with this message (the storage space and memory values might differ depending on the board used):
1525

1626
```
@@ -20,41 +30,44 @@ Learn about compilation errors in your sketch and how to resolve them.
2030

2131
* A sketch always needs to include a `setup()` and `loop()` function, even if they're not being used. You can use _File > Examples > 1.Basics > BareMinimum_ as a template.
2232

23-
* Libraries added with `#include` need to be installed. Try searching for the library name in the Library Manager (_Tools > Manage Libraries..._).
33+
* Libraries added with `#include` need to be installed. Learn how to [add libraries to Arduino IDE](https://support.arduino.cc/hc/en-us/articles/5145457742236-Add-libraries-to-Arduino-IDE).
2434

2535
---
2636

27-
## Interpreting the error message
37+
<a id="interpret"></a>
38+
39+
## How to interpret an error message
40+
41+
To get more information about the error, we need to check the console output. See the example below:
42+
43+
1. If a pop-up notification is still showing, close it by clicking the **x** in the top-right corner.
2844

29-
Arduino IDE displays compilation messages differently depending on the version:
45+
![Closing the pop-up notification.](img/ide-compilation-error-exit-status-1-x.png)
3046

31-
1. Check the IDE error message.
32-
* In IDE 1.x, it is displayed above the console window.
33-
* In IDE 2, it is displayed in a bottom-right pop-up.
34-
Sometimes, preceding lines can be more informative — check the console output.
47+
2. Find the console output panel.
3548

36-
2. Check the console output.
37-
* Compilation errors will often reference the row and column where the error was triggered, i.g. `Blink:29:1` (line 29, 1 column).
38-
* You may have to scroll or expand the window width to see the entire message.
49+
![The error output in the console panel.](img/ide-compilation-error-exit-status-1-1.png)
3950

40-
3. Look for highlights in the editor:
41-
* In IDE 1.x, the **line** where the error occurred is highlighted in red.
42-
* In IDE 2, the **character** where the error occurred is underlined in red.
43-
* The line causing the error may be before the line where it was triggered. In the example above, line 28 is missing a semicolon (`;`), but the error will be triggered by the unexpected closing bracket (`}`) in line 29.
51+
3. Read the first few lines. The following generic messages may appear near the end of the output:
4452

45-
<table class="img-captions">
46-
<tr>
47-
<td><img src="https://content.arduino.cc/assets/ide1-syntax-error-output-highlighted.png" alt="Compilation error in IDE 1.8.13, due to a missing semicolon."></td>
48-
<td><img src="https://content.arduino.cc/assets/ide2-syntax-error-output-highlighted.png" alt="Compilation error in IDE 2.0.0-3c6, due to a missing semicolon."></td>
49-
</tr>
50-
<tr>
51-
<td>Error output in IDE 1.x.</td>
52-
<td>Error output in IDE 2.</td>
53-
</tr>
54-
</table>
53+
* `collect2: error: ld returned 1 exit status`
54+
* `exit status 1`
55+
* `Compilation error: exit status 1`
56+
57+
These generic error messages indicate that the compilation process failed but don't provide specific details about the error, so it's important to read the lines before them.
58+
59+
4. 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.
60+
61+
5. In this example, the message <code>...main.ccp:43: undefined reference to \`setup'</code> is the most informative:
62+
63+
![Scrolling right in the console panel to reveal more output.](img/ide-compilation-error-exit-status-1-2.png)
64+
65+
In this case, the error was caused by a missing `setup()` function.
5566

5667
---
5768

69+
<a id="troubleshoot"></a>
70+
5871
## Troubleshoot a specific error
5972

6073
<table>

0 commit comments

Comments
 (0)