Fix Arduino “undefined reference to setup”
Identify a linker error caused by a missing global void setup() and test the corrected sketch with the same AVR build.
Check that setup exists as a global function
The Arduino core calls setup() after initialization, then runs loop(). If the linker cannot find setup, inspect the name, case, scope and signature. Setup() with a capital S does not define the expected function. A declaration with a semicolon also does not create a definition.
Restore the entry point and rebuild
Start with a global void setup() with no arguments and a body, even if the body is empty. Preserve one global void loop() alongside it. If the diagnostic names main.cpp in the core, fixing the called function in your sketch is usually the next step. Do not edit the bundled core to silence the message.
Open the exact Uno example
Renaming setup to Setup produces the linker diagnostic. Restoring the lowercase spelling compiles.
void setup() {}
void loop() {}Verified with [email protected] on Uno R3 (2026-12-05 UTC). The intentionally broken variant reproduced the named diagnostic. This check did not use physical hardware.