Arduino IDE Include Search Path

Files ending in .h can be included using the Arduino IDE.

If the #include is in a .ino sketch file:

#include “filename.h”
– first looks for the file in the same directory as your main .ino sketch file – NOT in any subdirectories of that directory
– then follows the same search sequence as below.
– if the file is not found the compiler issues an error message and stops

#include <filename.h>
– Looks in /Applications/Arduino/Contents/Resources/Java/hardware/arduino/cores/arduino/
– Looks in all directories in Documents/Ardiuno/libraries/ (possibly in reverse alphabetical or last created order)
– Looks in all directories in /Applications/Arduino/Contents/Resources/Java/libraries (ditto)
– if the file is not found the compiler silently continues without it

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If the #include is in a user library file

#include “filename.h”
– Looks in same directory as the including file
– Looks in /Applications/Arduino/Contents/Resources/Java/hardware/arduino/cores/arduino/
– Looks in ./utility subdirectory of the directory containing the including file
– Otherwise ends with a compiler error message

#include <filename.h>
– Looks in /Applications/Arduino/Contents/Resources/Java/hardware/arduino/cores/arduino/
– Looks in all directories in Documents/Ardiuno/libraries/ (possibly in reverse alphabetical or last created order)
– Looks in ./utility subdirectory of the directory containing the including file
– if the file is not found the compiler silently continues without it

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I am guessing that the system library files operate in the same way:

#include “filename.h”
– Looks in same directory as the including file
– Looks in /Applications/Arduino/Contents/Resources/Java/hardware/arduino/cores/arduino/
– Looks in ./utility subdirectory of the directory containing the including file
– Otherwise ends with a compiler error message

#include <filename.h>
– Looks in /Applications/Arduino/Contents/Resources/Java/hardware/arduino/cores/arduino/
– Looks in all directories in /Applications/Arduino/Contents/Resources/Java/libraries
– Looks in ./utility subdirectory of the directory containing the including file
– if the file is not found the compiler silently continues without it

About Ian

I am a New Zealand and EC citizen, living and working in Hastings in the North Island of New Zealand. On March 5th in 2004 I retired from exactly 30 years with IBM UK Ltd, working in the Hursley software development lab near Winchester in the south of England. I am now an IBM Distinguished Engineer emeritus, working to my own agenda while retaining access to my colleagues and information inside IBM.
This entry was posted in General. Bookmark the permalink.

Comments are closed.