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

Home / Errors
Arduino build error

# undefined reference to `readSensor()'

The code compiled. The linker, which joins the pieces, could not find the body of a function that your code calls.

Try the fixed sketch in Mokxi See the causes

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

The message

## What the Arduino IDE prints

Output window

The function was announced but never written, or it was written with different parameters, or its file is not part of the build.

Mokxi's linker, lld, words it as undefined symbol: readSensor().

Causes

## The 2 usual causes with the fix

### 1A function is declared and has no body

A line such as int readSensor(); only announces the function. Write its body, or remove the call.

Broken

Fixed

Mokxi’s build tab says: readSensor is used, but its code is in no file of the build.

Try this fix in Mokxi

### 2The body has different parameters than the declaration

A function is known by its name and its parameter types together. int blink(int) and int blink() are two functions.

Broken

Fixed

Mokxi’s build tab says: blink is used, but its code is in no file of the build.

Try this fix in Mokxi

FAQ

## Questions and answers

### What does "undefined reference" mean?

The linker found a call to a function and no definition of it anywhere in the build.

### Why does it appear after the code compiled?

Compiling checks each file alone. Linking joins them and only then finds what is missing.

### Can a library cause it?

Yes, when a header was included and the matching .cpp file is not part of the build. Reinstall the library, and in a project add its .cpp file.

Next

## More errors and the longer guide

- multiple definition of 'counter'
- undefined reference to `setup'

The longer guide to this error All Arduino errors
