Source: https://mokxi.com/errors/undefined-reference-to-setup
Updated: 2026-11-16

Home / Errors
Arduino build error

# undefined reference to `setup'

Every sketch needs a void setup() and a void loop(). The Arduino code that starts your program calls both by name.

Try the fixed sketch in Mokxi See the causes

- Build error
- 2 common causes
- Seen 754 times in failed builds on Mokxi in the 30 days to November 16, 2026.

The message

## What the Arduino IDE prints

Output window

If either is missing or misspelled, the linker finds nothing to call.

Mokxi's linker, lld, words it as undefined symbol: setup(), and the build tab explains what a sketch needs.

Causes

## The 2 usual causes with the fix

### 1setup or loop is spelled differently

The names are lowercase. void Setup() is a different function, and the linker never finds setup.

Broken

Fixed

Mokxi’s build tab says: sketch.ino line 1 has Setup(), but Arduino calls setup()

Try this fix in Mokxi

### 2loop() was deleted or left out

A sketch with only setup() still needs an empty loop().

Broken

Fixed

Mokxi’s build tab says: The sketch has no loop() function.

Try this fix in Mokxi

FAQ

## Questions and answers

### Does every sketch need both functions?

Yes. Even a sketch that does nothing in loop() needs the empty function.

### Why does the message name setup and not my code?

The code that runs when the board starts calls setup() and loop(). The linker reports that call as the missing piece.

### Can setup() be in another tab?

Yes, in a .ino tab, which joins the sketch. A tab that is not a .ino, .cpp or .c file is not built.

Next

## More errors and the longer guide

- undefined reference to `readSensor()'
- multiple definition of 'counter'

Every Arduino compile error All Arduino errors
