I've created my own library from some code that works and I thought would be useful to re-use. I'm using an Apple Mac. I created a folder of the same name as the library in:
\Arduino\libraries\
we'll call it:
deque
which is where I have a couple of other libraries I imported. I created the deque.h file (it's a templated class so no .cpp file). I also created a keywords.txt file.
Re-started Auduino IDE, and the new library is listed. I can 'include the library' from the 'sketch' menu. But when I compile I get:
Arduino: 1.6.5 (Mac OS X), Board: "Arduino/Genuino Uno"
In file included from Controller.cpp:1:0:
Controller.h:1:19: fatal error: deque.h: No such file or directory #include <deque.h>
^
compilation terminated.
Error compiling.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Any idea what I need to do to correct this error? But the file does exist!
As a general rule (i.e., not etched in stone), a library directory name shares the same name as the header (.h) and C++ (.cpp) files. Sometimes, when you extract a library from a downloaded ZIP file, it will expand to a directory with some name appended to it. For example, you might have a file:
It is complaining because you're including Controller in your .ino file and not deque.h
The IDE can only find files that are included from the .ino file. If one of the headers includes something that isn't in the same folder with it, then the .ino has to have an include for it as well.
Are controller.h and deque.h in the same folder? If not, include deque.h in the .ino file and the problem will be solved.
Delta_G:
It is complaining because you're including Controller in your .ino file and not deque.h
The IDE can only find files that are included from the .ino file. If one of the headers includes something that isn't in the same folder with it, then the .ino has to have an include for it as well.
Are controller.h and deque.h in the same folder? If not, include deque.h in the .ino file and the problem will be solved.
The deque.h is in the \Arduino\libraries\deque\ folder. Then the Controller.h starts with:
... because the class in my Controller.h and Controller.cpp uses the deque class, as does the .ino file. If I put the deque.h in the same folder as the program and start my Controller.h with:
I've added the deque.h file to the program files rather than in the libraries folder. Changed #include <deque.h> in the Controller.h to #include "deque.h", now it all compiles again. I can get on with my project. Just that I would like to know why this wasn't working. I even added the deque folder to a .zip file and imported the library that way, it created the deque folder in the libraries folder and on re-starting the Arduino IDE sure enough it was available, but on 'including library' into the Controller.h file it doesn't compile due to file not found!!