I tried to do this, and looked into it, a few years ago, but it doesn't appear to be possible to do what you want to do. This guy was having the same issue, #include statement with relative path.
Seems like either Michel's suggestion or copying them (which is a pain) will work, from Can I include a header file that is not a library?:
If the include file is part of a single Sketch, instructions are
here... http://www.arduino.cc/en/Hacking/BuildProcess [new
link]
If the include file is meant to be shared by multiple Sketches then...
- Close the Arduino IDE
- Navigate to the
{Arduino}\hardware\libraries
directory
- Create a subdirectory. I suggest something like
MyCommon
.
- In the new subdirectory, create a header file. I suggest something like
MyCommon.h
.
- Open the new header file, edit it as you wish, and save it
- Open the Arduino IDE
- Create or open a Sketch
- Add a
#include
to the top of the Sketch that references your new include file
This is why relative paths are not supported, from Re: how to include header file from previous folder?
Enable verbose mode when compiling. Navigate to the Testing.cpp file that is created from the Testing .ino file. Go up one level. Do you see the files you are trying to include?
and from Re: how to include header file from previous folder? (emphasis is mine)
The reason for having you go look at the something
like/AppData/Local/Temp/build/sketch folder was
to make you think about what the build process is doing, and maybe
think that you could google Arduino + Build to get more details.
The IDE copies your sketch, and stuff #included by your sketch to a
build directory.
If you #include , the file header.h, and everything else in
the directory it is in, will be copied to the build directory, too.
If you #include "header.h", the file header.h, and everything else in
the directory it is in, will be copied to the build directory, too.
The difference between <> and "" is where the header.h file is looked
for. "" looks in the current directory. <> looks in the library
directories.
If the token between the <> or the "" is not found in the appropriate
folder, you are not told that; nothing gets copied, though.
But, that explains why relative names are useless. A sketch directory
might contain a file called header.h. It will not contain a file
called ..\header.h, because ..\header is NOT a valid file name.
Note that I did NOT say that ..\header.h is not a valid NAME. I said
that it is not a valid FILE NAME.
Only file names between the <> or "" are possible, as far as the IDE
is concerned.
If you do not like that, you are free to not use the IDE.
Finally from Re: How to specify a path to a specific header file?
The Arduino system has some severe limitations in its ability to work sensibly with the file system - can be a real PITA.
mklink
on Windows