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?
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?
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.
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
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.