finding libraries from non-PDE files

I'm still new to the Arduino way of doing things and I've got an odd issue that doesn't really come up in straight C/C++.

I'm trying to use an Arduino library in another .cpp file. The Arduino environment treats pde's a bit magically so code like #include <EEPROM.h> works from a pde but not from another cpp file.

Is there any way to get the environment to find the header short of providing the full path (as done here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1294353565). My code needs to compile regardless of the user's arduino install location.

To give a concrete example:

main.pde:

#include <EEPROM.h>
//... some code

works fine.

but
main.pde:

#include "foo.h"
//... rest of code here

foo.h:

#include<EEPROM.h>
//... rest of foo.h

foo.cpp:

#include "foo.h"
//... some code

won't work because it can't find EEPROM.h

Put yet another way, how can i add command line args to the compile step (so i can pass -I ... to gcc)?

Not a perfect solution but you could have your users add an environment variable that specifies the header file include path...

Thanks for the reference. I'm sure it'll come in handy another day :wink:

I actually ended up rewriting the part of the library I needed in C in a way that suited my odd application better. (it was the AF motor library)

Still, if anyone knows how to do what i asked in my OP I'd love to know the answer.

The Arduino environment treats pde's a bit magically so code like #include <EEPROM.h> works from a pde but not from another cpp file.

Not quite true. The include file can be found from a cpp file as easily as from a pde file. The issues is what gets compiled.

Every pde file in a directory gets compiled, along with each cpp file whose header file is #included in a pde file. A cpp file whose header file is not included in sketch, but that is not included a sketch, will not be compiled.

The linker obviously only deals with what was compiled.

If you have a header file, MyLib.h, that includes EEPROM.h, and you include MyLib.h in MySketch.pde, then MySketch.pde and MyLib.cpp will be compiled, but EEPROM.cpp will not, so any function that MyLib.cpp calls will not be available for linking.

If you include EEPROM.h in MySketch.pde, then EEPROM.cpp WILL be compiled, and MyLib.cpp's calls to EEPROM functions will be resolved.

There is a difference between
#include <EEPROM.h>
and
#include "EEPROM.h"
that affects WHERE the header files are looked for. I haven't investigated enough to determine definitely which should be used when, but when one doesn't work for me, I use the other.