I made a private library (RobuinoCore.h) that use some libraries:
#include <SPI.h> #include <ESP8266.h>
.....
My sketch has a include of my private library:
#include "RobuinoCore.h"
The IDE display error:
/home/odilon/Arduino/libraries/RobuinoCore/RobuinoCore.h:22:20: fatal error: SPI.h: No such file or directory #include <SPI.h>
^
compilation terminated.
If I insert the include (the same !!) into my sketch:
#include <SPI.h> #include <ESP8266.h>
The compilations goes Ok.
Why this happen ?
Why can I call the libraries that are installed properly into my system and include it from my private library ?
Anything included in the libraries has to either be in the same folder with the code that includes it or must be included in the sketch. That's just the way it works with the IDE. It looks at the sketch to figure out what folders to gather up into a temporary location for compilation.
When I include the library "ESP8266.h" into a sketch, it is not in the same folder that is the library "SoftwareSerial.h", but there is a include "SoftwareSerial.h" into "ESP8266.h" and the IDE locate the library.
I don't have to include the "SoftwareSerial.h" from my sketch, just the "ESP8266.h" do this. And many others libraries work this way.
I suspect the problem is due to the fact that the Arduino IDE copies your .ino file to another directory before it starts working on it. Then relative references to other external files no longer work.
I managed to get around that problem by making all the #includes in the .ino file into absolute references to the full path for the library files. But that is a real PITA because it is not portable.
Have you set the Sketchbook directory to the directory one above your sketch directory? The Sketchbook directory is set in File/Preferences/Settings/Sketchbook location:. There is an edit box into which the Sketchbook directory is put.
Sketchbook Directory: D:\Arduino
My project directory: D:\Arduino\MyProject
User Libraries dir: D:\Arduino\Libraries
OneLibrary dir: D:\Arduino\Libraries\OneLibrary
OneLibrary header/Body file names: OneLibrary.h OneLibrary.cpp