You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/Software Support/Compilation/If-your-sketch-doesnt-compile.md
+37-24Lines changed: 37 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,22 @@ id: 4402764401554
5
5
6
6
Learn about compilation errors in your sketch and how to resolve them.
7
7
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
+
8
14
---
9
15
16
+
<aid="quick-checks"></a>
17
+
10
18
## Quick checks
11
19
12
20
* Make sure your error occurs during compilation by clicking **Verify** instead of **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).
13
21
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
+
14
24
* A successful compilation will always finish with this message (the storage space and memory values might differ depending on the board used):
15
25
16
26
```
@@ -20,41 +30,44 @@ Learn about compilation errors in your sketch and how to resolve them.
20
30
21
31
* 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.
22
32
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).
24
34
25
35
---
26
36
27
-
## Interpreting the error message
37
+
<aid="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.
28
44
29
-
Arduino IDE displays compilation messages differently depending on the version:
45
+

30
46
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.
35
48
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
+

39
50
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:
44
52
45
-
<tableclass="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
+

64
+
65
+
In this case, the error was caused by a missing `setup()` function.
0 commit comments