undefined reference to 'loop'
The Arduino compiler toolchain requires every sketch to define a loop() function. Omitting this function causes a linker error when the core attempts to resolve it during compilation.
This diagnostic is a linker error indicating that the symbol for the `loop` function was referenced by the compiled program, but its implementation could not be found anywhere in the compiled object files or linked libraries. In the context of the Arduino environment, this specifically means the standard Arduino core's hidden entry point (`main.cpp`) contains a mandatory call to `loop()`, but the user's sketch or C++ source code has failed to provide a definition for it.
The standard Arduino C++ entry point is defined in a core library file, typically named `main.cpp`. This `main()` function initializes the microcontroller hardware, calls the user-provided `setup()` function once, and then enters an infinite loop that repeatedly calls the `loop()` function. Because `main.cpp` declares `loop()` as an external function it expects to execute, the compiler's linker must resolve this symbol during the final build step. If a sketch is written without defining a `void loop()` function, or if a typographical error alters its name (such as capitalizing it as `Loop()`), the linker cannot satisfy the dependency originating from `main.cpp` and throws the 'undefined reference' error.
void setup() {
// Hardware initialization
pinMode(13, OUTPUT);
}
// Intentionally missing void loop() definition
Ensure that the sketch provides a valid definition for the `void loop()` function with the exact lowercase spelling, even if the function body is left empty.
```C++
void setup() {
// Hardware initialization
pinMode(13, OUTPUT);
}
void loop() {
// Required by Arduino core, can be left empty if unused
}
```