This seems to be a general problem of the Arduino IDE: It only recognizes libraries that are included in the (primary) .ino
file.
If you look at the invocation of the compiler, the path to any given library is only added if this library's header file is included in the .ino
file.
I tested this with the EEPROM library. If this library is included in the .ino
file, the compiler is called with
avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=100 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/eightanaloginputs -I/usr/share/arduino/libraries/EEPROM /tmp/build2678545434708654378.tmp/test.cpp -o/tmp/build2678545434708654378.tmp/test.cpp.o
where the important part is the -I/usr/share/arduino/libraries/EEPROM
.
If I now remove #include <EEPROM.h>
(but still have it in another header file which in turn is included in the .ino
as in your case), the compiler call changes to
avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=100 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/eightanaloginputs /tmp/build2678545434708654378.tmp/test.cpp -o/tmp/build2678545434708654378.tmp/test.cpp.o
where now the include path to the library is missing.
TL;DR
If you need to use a library, just (also) add an include to the .ino
file. It doesn't cost you anything and will solve your problem ;)
#include <file>
vs. #include "file"
From the gcc documentation:
- #include <file> is used for system header files. It searches for a file named file in a standard list of system directories. [...]
- #include "file" is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the quote directories and then the same directories used for <file>. [...]