[SOLVED] Correct use of #include ? (for files not in library)

I am doing some experimenting with the RF24 library.

There are three .h files and 1 .cpp file. If I put all those files in the same directory as my .ino file and use the style #include "RF24r.h" it compiles as expected.

However I would like to have those 4 files in the next higher level directory so that I can access them from two different .ino files. But when I use the style #include "../RF24r.h" it cannot find the files. And I did check that ls ../RF24r.h can find the file

What am I missing that is blindingly obvious to everyone else?

...R

Why not place them in the library folder as intended?

What am I missing that is blindingly obvious to everyone else?

The fact that the code is not compiled in place. The files are copied to a build directory. In the build directory, all the files are at the same level.

septillion:
Why not place them in the library folder as intended?

Because it is easier to edit them when they are part of my project. I will probably want to keep several different version in parallel as I experiment. I don't want to clutter up the libraries folder with all that junk.

PaulS:
The fact that the code is not compiled in place. The files are copied to a build directory. In the build directory, all the files are at the same level.

Does that mean that C/C++ cannot deal with #include the way I am trying to do it?
Or is it specific to the Arduino system.
Is there any other solution that will allow me to keep the files in a directory close to the .ino files?

...R

It's an Arduino think if I'm correct.

But I don't think there's another way. This is why there is a library folder... And it's not that far off..

[Sketchbook][Your project]
and
[Sketchbook]\libraries

septillion:
It's an Arduino think if I'm correct.

But I don't think there's another way.

Thanks.

This is a PITA. Why can't simple stuff work (don't bother to answer).

...R

This is a PITA. Why can’t simple stuff work

Because it was “more important” for Arduino sketches to be able to say “#include <library.txt>” and not have to also add the “-I /Applications/Arduino.app/Contents/java/libraries/library” anywhere than it was to support the full range of possible #include syntax available in C.

I found a solution ...

In the original code it had two #includes in the .ino file and the other two files were #included from those two files.

#include "nRF24L01r.h"
#include "RF24r.h"

Taking account of @PaulS' comment "The files are copied to a build directory" it occurred to me that if I referred to all 4 files in the .ino file then all 4 would be copied to the build directory. So I changed the above to

#include "/mnt/sdb1/SGT-Prog/Arduino/NRF24/NRF24andCypress/nRF24L01r.h"
#include "/mnt/sdb1/SGT-Prog/Arduino/NRF24/NRF24andCypress/RF24r.h"
#include "/mnt/sdb1/SGT-Prog/Arduino/NRF24/NRF24andCypress/RF24_configr.h"
#include "/mnt/sdb1/SGT-Prog/Arduino/NRF24/NRF24andCypress/RF24r.cpp"

And it compiled properly.

Note that the only change I have made is to the .ino file

...R

Isn't it the case that any files #included by a library always have also to be #included by the main .ino file ?

UKHeliBob:
Isn’t it the case that any files #included by a library always have also to be #included by the main .ino file ?

If that means that you are wondering how the code with only 2 #includes works - I don’t know the answer, but it does. Normally of course the style would be #include <nRF24L01.h>

I think it is because the IDE knows where the library files are, but does not know how to find them if they are not at that location.

…R