I'm trying to look through the Arduino core to find where "mySketch.ino" is included or implemented. In 'Arduino.h', the prototypes void setup(void) and void loop(void) are defined, in 'main.cpp', setup(void) and loop(void) are called, but I'm not sure where 'main.cpp' or any other related files makes a reference to the sketch.

Where does this occur?


1 Answer 1


Compilation doesn't start with the Arduino.h or the core files; rather, it starts with your own sketch, "whatever.ino". Your .ino file includes Arduino.h into the compilation which makes references to core modules. That compilation leaves many references to to be satisfied, and itself satisfies several - setup() and loop(), for two. At link time, the linker is told to read not only your compiled module(s), but also the compiled core files, from which it can extracts the modules required to satisfy references made by your compiled code. Then it combines your module, and those modules required by it, into the load file that avrdude uploads to the Arduino.

  • 1
    Just want to add, that the Arduino IDE also concatenates all the .ino files in the same sketch together; .cpp, files are compiled automatically as well, but are not modified like the .ino files.
    – esoterik
    Feb 20, 2019 at 4:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.