PDA

View Full Version : Another library fails to compile… any ideas why?



Constantin
11-30-2013, 02:14 PM
EEPROMEx is a really neat library (http://thijs.elenbaas.net/2012/07/extended-eeprom-library-for-arduino/), allowing the quick and easy writing of just about any type of variable or array to EEPROM.

Trouble is, it will compile just fine on an AVR but fails on the Teensy 3… error code follows:

In file included from EEPROMEx.ino:9:0:
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMEx.h:23:20: fatal error: EEPROM.h: No such file or directory
compilation terminated.

The weird thing is that EEPROM.h is present in my list of libraries (Teensy 1.17 + Arduino 1.05). Any idea what might be going on?

MichaelMeissner
11-30-2013, 02:53 PM
Try adding an explicit:



#include <EEPROM.h>


before the include of EEPROMEx.h. This sometimes helps when the IDE can't deduce it needs to include EEPROM.h on its own.

Constantin
11-30-2013, 03:16 PM
So, now the Example file included with the library no longer complains about the lack of EEPROM.h. However, it still fails to compile and unfortunately, this is way over my head. The most I got into CS was intro to program and data types was the next class. I presume the below makes a lot more sense to the likes of you, who will forget more about C in a given day than I'll ever know.


In file included from EEPROMEx.ino:9:0:
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMEx.h:51:26: warning: ISO C99 requires whitespace after the macro name [enabled by default]
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMEx.h:51:0: warning: "EEPROMSizeTeensy1" redefined [enabled by default]
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMEx.h:50:0: note: this is the location of the previous definition
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMEx.h:53:26: warning: ISO C99 requires whitespace after the macro name [enabled by default]
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMEx.h:53:0: warning: "EEPROMSizeTeensy2" redefined [enabled by default]
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMEx.h:52:0: note: this is the location of the previous definition
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMEx.h:54:0: warning: "EEPROMSizeTeensy3" redefined [enabled by default]
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMEx.h:39:0: note: this is the location of the previous definition
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMEx.h:166:22: error: conflicting declaration 'EEPROMClassEx EEPROM'
In file included from EEPROMEx.ino:8:0:
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROM/EEPROM.h:39:20: error: 'EEPROM' has a previous declaration as 'EEPROMClass EEPROM'
EEPROMEx.ino: In function 'void readAndWriteInt()':
EEPROMEx:80: error: 'class EEPROMClass' has no member named 'writeInt'
EEPROMEx:81: error: 'class EEPROMClass' has no member named 'readInt'
EEPROMEx.ino: In function 'void readAndWriteLong()':
EEPROMEx:100: error: 'class EEPROMClass' has no member named 'writeLong'
EEPROMEx:101: error: 'class EEPROMClass' has no member named 'readLong'
EEPROMEx.ino: In function 'void readAndWriteFloat()':
EEPROMEx:120: error: 'class EEPROMClass' has no member named 'writeFloat'
EEPROMEx:121: error: 'class EEPROMClass' has no member named 'readFloat'
EEPROMEx.ino: In function 'void updateAndReadDouble()':
EEPROMEx:140: error: 'class EEPROMClass' has no member named 'updateDouble'
EEPROMEx:141: error: 'class EEPROMClass' has no member named 'readDouble'
EEPROMEx.ino: In function 'void writeAndReadCharArray()':
EEPROMEx:161: error: 'class EEPROMClass' has no member named 'writeBlock'
EEPROMEx:161: error: expected primary-expression before 'char'
EEPROMEx:161: error: expected ';' before 'char'
EEPROMEx:162: error: 'class EEPROMClass' has no member named 'readBlock'
EEPROMEx:162: error: expected primary-expression before 'char'
EEPROMEx:162: error: expected ';' before 'char'
EEPROMEx.ino: In function 'void writeAndReadByteArray()':
EEPROMEx:184: error: 'class EEPROMClass' has no member named 'writeBlock'
EEPROMEx:184: error: expected primary-expression before '>' token
EEPROMEx.ino:184:47: warning: left operand of comma operator has no effect [-Wunused-value]
EEPROMEx.ino:184:56: warning: right operand of comma operator has no effect [-Wunused-value]
EEPROMEx:185: error: 'class EEPROMClass' has no member named 'updateBlock'
EEPROMEx:185: error: expected primary-expression before '>' token
EEPROMEx.ino:185:67: warning: left operand of comma operator has no effect [-Wunused-value]
EEPROMEx.ino:185:74: warning: right operand of comma operator has no effect [-Wunused-value]
EEPROMEx:186: error: 'class EEPROMClass' has no member named 'readBlock'
EEPROMEx:186: error: expected primary-expression before '>' token
EEPROMEx.ino:186:46: warning: left operand of comma operator has no effect [-Wunused-value]
EEPROMEx.ino:186:54: warning: right operand of comma operator has no effect [-Wunused-value]
EEPROMEx.ino: In function 'void waitUntilReady()':
EEPROMEx:212: error: 'class EEPROMClass' has no member named 'writeByte'
EEPROMEx:216: error: 'class EEPROMClass' has no member named 'isReady'
EEPROMEx:225: error: 'class EEPROMClass' has no member named 'writeLong'
EEPROMEx:229: error: 'class EEPROMClass' has no member named 'isReady'
EEPROMEx:237: error: 'class EEPROMClass' has no member named 'readLong'
EEPROMEx:241: error: 'class EEPROMClass' has no member named 'isReady'
EEPROMEx:256: error: 'class EEPROMClass' has no member named 'writeBlock'
EEPROMEx:256: error: expected primary-expression before '>' token
EEPROMEx.ino:256:47: warning: left operand of comma operator has no effect [-Wunused-value]
EEPROMEx.ino:256:55: warning: right operand of comma operator has no effect [-Wunused-value]
EEPROMEx:263: error: 'class EEPROMClass' has no member named 'updateBlock'
EEPROMEx:263: error: expected primary-expression before '>' token
EEPROMEx.ino:263:48: warning: left operand of comma operator has no effect [-Wunused-value]
EEPROMEx.ino:263:59: warning: right operand of comma operator has no effect [-Wunused-value]
EEPROMEx:270: error: 'class EEPROMClass' has no member named 'updateBlock'
EEPROMEx:270: error: expected primary-expression before '>' token
EEPROMEx.ino:270:48: warning: left operand of comma operator has no effect [-Wunused-value]
EEPROMEx.ino:270:59: warning: right operand of comma operator has no effect [-Wunused-value]
EEPROMEx:277: error: 'class EEPROMClass' has no member named 'readBlock'
EEPROMEx:277: error: expected primary-expression before '>' token
EEPROMEx.ino:277:46: warning: left operand of comma operator has no effect [-Wunused-value]
EEPROMEx.ino:277:54: warning: right operand of comma operator has no effect [-Wunused-value]
EEPROMEx.ino: In function 'void errorChecking(int)':
EEPROMEx:291: error: 'class EEPROMClass' has no member named 'writeLong'
EEPROMEx:297: error: 'class EEPROMClass' has no member named 'writeLong'
EEPROMEx.ino: In function 'void setup()':
EEPROMEx:309: error: 'class EEPROMClass' has no member named 'setMemPool'
EEPROMEx:313: error: 'class EEPROMClass' has no member named 'setMaxAllowedWrites'
EEPROMEx:318: error: 'class EEPROMClass' has no member named 'getAddress'
EEPROMEx:319: error: 'class EEPROMClass' has no member named 'getAddress'
EEPROMEx:320: error: 'class EEPROMClass' has no member named 'getAddress'
EEPROMEx:321: error: 'class EEPROMClass' has no member named 'getAddress'
EEPROMEx:322: error: 'class EEPROMClass' has no member named 'getAddress'
EEPROMEx:323: error: 'class EEPROMClass' has no member named 'getAddress'
EEPROMEx:324: error: 'class EEPROMClass' has no member named 'getAddress'

jimmayhugh
11-30-2013, 03:53 PM
I use this bit of code (http://playground.arduino.cc/Code/EEPROMWriteAnything) to save and retrieve my data structures to and from the Teensy 3.0. Hasn't failed me yet...

Constantin
11-30-2013, 05:20 PM
I use this bit of code (http://playground.arduino.cc/Code/EEPROMWriteAnything) to save and retrieve my data structures to and from the Teensy 3.0. Hasn't failed me yet...
And seems to work like a charm! You are the best! Thank you!

PaulStoffregen
11-30-2013, 08:16 PM
I'm looking into the EEPROMEx library now. There are multiple problems. I hope to have fixes soon....

PaulStoffregen
11-30-2013, 09:17 PM
Turns out there's a github repository for this library. I committed fixes here:

https://github.com/PaulStoffregen/Arduino-Libraries/tree/master/EEPROMEx

I'll also attach my patched copy to this message.

Teensy3 was missing one of the seldom-used AVR libc EEPROM library functions. I've added it. You'll need these 2 files, which go into hardware/teensy/cores/teensy3.

https://github.com/PaulStoffregen/cores/blob/master/teensy3/avr_functions.h
https://github.com/PaulStoffregen/cores/blob/master/teensy3/eeprom.c

With these 2 files (which I'll put in all future Teensyduino installers) and the patched library, it should compile and (hopefully) work correctly.

Please let me know how this works for you?

duff
11-30-2013, 10:01 PM
Please let me know how this works for you?


I tried to compile the library you posted and it still gives error with the example programs under teensduino-1.17rc2 and arduino1.0.5. I made no changes to anything, just installed the library.
Here are the error's:

EEPROMEx.pde


/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMex.cpp: In member function 'bool EEPROMClassEx::isReady()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMex.cpp:91:25: error: 'eeprom_is_ready' was not declared in this scope


EEPROMBackup.pde


In file included from EEPROMBackup.pde:18:0:
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMBackupVar.h: In constructor 'EEPROMBackupVar<T>::EEPROMBackupVar(T, int, compareFunction, long unsigned int)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMBackupVar.h:41:24: error: 'class EEPROMClassEx' has no member named 'getAdress'
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMBackupVar.h: In member function 'void EEPROMBackupVar<T>::initialize(T)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMBackupVar.h:48:24: error: 'class EEPROMClassEx' has no member named 'getAdress'


EEPROMVar.pde


In file included from EEPROMVar.pde:10:0:
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMvar.h: In constructor 'EEPROMVar<T>::EEPROMVar(T)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMvar.h:29:20: error: 'class EEPROMClassEx' has no member named 'getAdress'

duff
11-30-2013, 10:08 PM
nevermind I didn't install the updated core files that you clearly stated needed to be installed, too much turkey!

duff
12-01-2013, 05:17 PM
nevermind I didn't install the updated core files that you clearly stated needed to be installed, too much turkey!

ok i spoke too soon, EEPROMEx.pde compiles fine but the other two examples do not. I updated the eeprom.c and avr_functions.h core files.

EEPROMBackup.pde errors


In file included from EEPROMBackup.pde:18:0:
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMBackupVar.h: In constructor 'EEPROMBackupVar<T>::EEPROMBackupVar(T, int, compareFunction, long unsigned int)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMBackupVar.h:41:24: error: 'class EEPROMClassEx' has no member named 'getAdress'
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMBackupVar.h: In member function 'void EEPROMBackupVar<T>::initialize(T)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMBackupVar.h:48:24: error: 'class EEPROMClassEx' has no member named 'getAdress'


EEPROMVar.pde errors


In file included from EEPROMVar.pde:10:0:
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMvar.h: In constructor 'EEPROMVar<T>::EEPROMVar(T)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/EEPROMEx/EEPROMvar.h:29:20: error: 'class EEPROMClassEx' has no member named 'getAdress'


haven't really looked into these errors yet.

duff
12-04-2013, 12:35 PM
Am I the only one getting this error on the example programs?

PaulStoffregen
12-04-2013, 12:59 PM
Opps, looks like I only tested 1 of the 3 examples!

The other 2 have another problem, unrelated to Teensy. Looks like "getAdress" was at some point corrected for spelling to "getAddress", but it wasn't fully updated in all locations.

Here's a patch to fix the problem:

https://github.com/PaulStoffregen/Arduino-Libraries/commit/bbf4ee382ec226374f5371ff7946f9c86d4a755f

duff
12-04-2013, 01:10 PM
So I got EEPROMBackup to compile. There was a spelling error in EEPROMBackupVar.h line 41 & 48:


41: baseAddress = EEPROM.getAdress(sizeof(T)*adressRange);
48: baseAddress = EEPROM.getAdress(sizeof(T)*adressRange);

Adress should be Address!

That being said I'm still getting a error with EEPROMVar.pde:


EEPROMVar.pde: In function 'void readAndWriteVar(EEPROMVar<float>&)':
EEPROMVar:34: error: 'class EEPROMVar<float>' has no member named 'getAddress'


So the float class does not support getAddress i guess, have to look into this also.

haha, my dog was chewing my shoes when u replied.

thijse
12-07-2013, 11:05 AM
Hi, Great to hear the library is being used! Paul submitted a bunch of fixes, so now the version on Github should not give any issues anymore. I will try to update the zip file later in the day.

I would be very interested to hear what people use the library for. If you want please post a reaction on my blog.

A side-note: I have removed the EEPROMBackupvar class for now. It is meant as a naive wear leveling mechanism, but this version only works in a limited set of cases. I'll change it into a more general version and re-add it when I have some time.

Thijs