Hey everyone,
I am writing a library that depends upon the Wire library. I needed to add some extra functionality to the Wire library so I created an extra method. But when I compile my test sketch I receive this error:
/var/folders/q7/pf2zqzhj5gx2_40kld54z3b00000gp/T/build7775033036328170875.tmp/CapTouch/CapTouch.cpp.o: In function `CapTouch::executeCommand(command, unsigned char, unsigned char const*)':
/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/CapTouch/CapTouch.cpp:158: undefined reference to `TwoWire::readSlave(unsigned char)'
/var/folders/q7/pf2zqzhj5gx2_40kld54z3b00000gp/T/build7775033036328170875.tmp/CapTouch/CapTouch.cpp.o: In function `CapTouch::start()':
/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/CapTouch/CapTouch.cpp:66: undefined reference to `TwoWire::readSlave(unsigned char)'
collect2: error: ld returned 1 exit status
Error compiling.
In my implementation of the Wire library I believe I have implemented my method correctly. Here is my function prototype:
public:
TwoWire();
void begin();
...
uint8_t readSlave(uint8_t);
uint8_t requestFrom(uint8_t, uint8_t);
...
And in Wire.cpp
uint8_t TwoWire::readSlave(uint8_t address) {
uint8_t tmp __atribute((unused));
...
I then use a script to place both of these in .../arduino/avr/libraries/Wire/. And this appears to be working correctly. When I look at the compilation output I see
/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/Wire.cpp -o /var/folders/q7/pf2zqzhj5gx2_40kld54z3b00000gp/T/build7775033036328170875.tmp/Wire/Wire.cpp.o
And this file at this location has the correct changes that I made. I have tried restarting the Arduino IDE and deleting the temporary build directories but these did not solve the problem. It also appears to be using the correct object file when it does final compilation
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-gcc -w -Os -Wl,--gc-sections -mmcu=atmega328p -o /var/folders/q7/pf2zqzhj5gx2_40kld54z3b00000gp/T/build7775033036328170875.tmp/APITest.cpp.elf /var/folders/q7/pf2zqzhj5gx2_40kld54z3b00000gp/T/build7775033036328170875.tmp/APITest.cpp.o /var/folders/q7/pf2zqzhj5gx2_40kld54z3b00000gp/T/build7775033036328170875.tmp/Wire/Wire.cpp.o /var/folders/q7/pf2zqzhj5gx2_40kld54z3b00000gp/T/build7775033036328170875.tmp/Wire/utility/twi.c.o /var/folders/q7/pf2zqzhj5gx2_40kld54z3b00000gp/T/build7775033036328170875.tmp/CapTouch/CapTouch.cpp.o /var/folders/q7/pf2zqzhj5gx2_40kld54z3b00000gp/T/build7775033036328170875.tmp/core.a -L/var/folders/q7/pf2zqzhj5gx2_40kld54z3b00000gp/T/build7775033036328170875.tmp -lm
I have tried making other changes to Wire.cpp in existing methods and none of those were present either. I also move my CapTouch library to .../arduino/avr/libraries/CapTouch/ and it is clearly found. I can open my CapTouch examples through the Arduino IDE GUI.
I am using an Arduino Uno. From what I see, it appears to be using a different version of the Wire library. But I don't see how that is possible when looking at the compilation output. I would appreciate any insight, I am probably making a stupid mistake.