How to include from subfolder of sketch folder

pert:
In recent versions of the Arduino IDE(including 1.6.10) if you want to include libraries from the sketch folder you need to put them in a src subfolder. For example:

Blink
|_Blink.ino
|_src
|_BlinkLib
|_BlinkLib.h

#include "src/BlinkLib/BlinkLib.h"

There was lots of discussion about this in a github issue related to this.
See this github issue for the gory details: Subfolders can no longer be included · Issue #5186 · arduino/Arduino · GitHub
The IDE copies the user sketch directory and files over to a working directory where it does the build and recently the IDE was modified to not copy any subdirectories except src so any headers in directories other than under src would not work. However after much discussion the Arduino team decided to change their mind and fixed it so that other sub directories would work again for include files which is the way it used to work.
I've not tested it but think the latest IDE (1.8.0) is now working the way it used to work and sub directories for header files works again, so depending on which version of the IDE it may or may not work.

--- bill

1 Like