Using builtin libraries in custom libraries

Maybe I am missing something simple,

I am writing a library serial messaging protocol for the arduino based upon Mojobus protocol, it allows addressing and multiple commands to be sent (and therefore it is RS485 capable). It used callbacks to update device states.

One thing I would like to do is include the EEPROM.h file in my libraries .cpp file. I want to be able to store the device addresses and baud rates on restarts.

When I do an #include <EEPROM.h> i get an error:

20: error: EEPROM.h: no such file or directory In member function ...

When I include the EEPROM.h header in my .pde it works fine and no error(even though I don't use EEPROM in the .pde).

I assume the arduino environment is not recognizing the include statement in the my .cpp files and not including the necessary header and .o files for the library when it is organizing the files to compile.

Is there a way to bypass this?

Thanks in advance!

The code is available here.
http://code.google.com/p/mojoduino/source/browse/#svn/trunk

I am adding #include <EEPROM.h> to the top of mojo.cpp.

This...

/*
mojo.cpp - Library for MojoBus communication.
Created by Henry Herman, October 18, 2009.
Released under the BSD License.
*/
extern "C" {
    #include <stdlib.h>
}


#include <EEPROM.h>
#include "WProgram.h"
#include "HardwareSerial.h"

...works for me. I'm using Arduino 15. Which Arduino are you using?

Thanks for looking at this...

I'm using Arduino 0017 on WindowsXP

I just commited to the svn, the head now represents files that are giving me the error.

When I remove the comment in Mojodevice.pde there is no error

//#include <EEPROM.h>  // <-- Doesn't work with this commented out

#include "mojo.h"
#include "mojodispatch.h"
#include "mojocallbacks.h"

void Hello( Command &cmd ) {
  Serial.println("Hello, World!");
  cmd.setReply("WORLD!");
}

Error:

20: error: EEPROM.h: No such file or directory In member function 'void Mojo::setAddress(char)':
In member function 'void Mojo::loadAddress()':

You assistance is much appreciated.

I did a little digging and realized the EEPROM.h library was only a light wrapper around the avr/eeprom.h library. By using the avr library I avoid the problem.

I would still like to know why it does not work in 0017....

Now I get an error as well. It appears the linker is instructed to only include libraries referenced in the PDE file.

Someone who's familiar with the IDE source code may be able to indicate if the behaviour is by design, because of a deficiency, or the result of a bug. In any case, for now, you're left with modifying the IDE source code to get the behaviour you want.

Sorry I can't be the bearer of better news!

Hi,
Same problem here:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1255235742

You cannot use an existing library from a new arduino lib.

The current Arduino software is designed that way. Could be changed, but would require some changes to the source-code and a new library install procedure.

Eberhard

Thanks for the help,

I will work around it by using the avr/* libraries.