Hi there C/CPP Experts,
im struggeling with strange none-intuitive error messages in the arduino 1.01 IDE when using my experimental libraries for buttons and leds.
Here is the list of error messages the compiler complains about:
myLed001\Led.cpp.o: In function `~Led':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:29: multiple definition of `Led::~Led()'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:29: first defined here
myLed001\Led.cpp.o: In function `~Led':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:29: multiple definition of `Led::~Led()'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:29: first defined here
myLed001\Led.cpp.o: In function `Led::setMode(unsigned char)':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:32: multiple definition of `Led::setMode(unsigned char)'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:32: first defined here
myLed001\Led.cpp.o: In function `Led::getPin()':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:61: multiple definition of `Led::getPin()'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:61: first defined here
myLed001\Led.cpp.o: In function `Led::getMode()':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:67: multiple definition of `Led::getMode()'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:67: first defined here
myLed001\Led.cpp.o: In function `Led::setFlash(int, int)':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:69: multiple definition of `Led::setFlash(int, int)'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:69: first defined here
myLed001\Led.cpp.o: In function `Led::setBlink(int)':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:81: multiple definition of `Led::setBlink(int)'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:81: first defined here
myLed001\Led.cpp.o: In function `Led::off()':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:55: multiple definition of `Led::off()'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:55: first defined here
myLed001\Led.cpp.o: In function `Led::on()':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:49: multiple definition of `Led::on()'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:49: first defined here
myLed001\Led.cpp.o: In function `Led::doFlashy()':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:132: multiple definition of `Led::doFlashy()'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:132: first defined here
myLed001\Led.cpp.o: In function `Led::toggle()':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:92: multiple definition of `Led::toggle()'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:92: first defined here
myLed001\Led.cpp.o: In function `Led::doBlinky()':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:125: multiple definition of `Led::doBlinky()'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:125: first defined here
myLed001\Led.cpp.o: In function `Led::update()':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:104: multiple definition of `Led::update()'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:104: first defined here
myLed001\Led.cpp.o: In function `Led::setOn()':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:42: multiple definition of `Led::setOn()'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:42: first defined here
myLed001\Led.cpp.o: In function `Led::setOff()':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:35: multiple definition of `Led::setOff()'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:35: first defined here
myLed001\Led.cpp.o: In function `Led':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:13: multiple definition of `Led::Led(unsigned char)'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:13: first defined here
myLed001\Led.cpp.o: In function `Led':
D:\DATEN\Dokumente\Arduino\arduino-1.0.1\libraries\myLed001/Led.cpp:13: multiple definition of `Led::Led(unsigned char)'
Led.cpp.o:C:\Users\user\AppData\Local\Temp\build4304156794175371655.tmp/Led.cpp:13: first defined here
To clear things up:
i once made a led and a button library (cpp + h files) within the sketch folder using #include "Led.h" #include "Button.h" to import them.
they worked just fine.
yesterday to save my work i copied those two libraries to the Arduino 1.01 Library folder. each in seperate subdir with the exact same foldername as the class name.
even though i wanted to keep on using my "local libs" (local to the adruino sketchs folder) i was NOT changing the includes into something like #include and stuck with the #include "mylib.h"
However.. things started to get strange here. even though i would expect the compiler from still using my local lib files, it somehow sees/uses those libs in the library/ folder of the arduino ide and now complains about multiple definitions.
Then things gets even worse when i try to rename those libs and folders in the arduinos library directory to avoid collisions. but it sucks.
The Problem seems to go away if i remove my libs from the Arduino/library folders again and just have it with my arduino sketch code in the same folder.
Should not there be a way to have multiple versions ob my libraries laying around and exclusively import/include a single specific one without colliding somewhere somehow ?!?
Anything i should do better?
thanks in advance for any useful advice.
Here is my example Button.h
/* Simple Button Class for Arduino 1.x by Axel Werner [mail@awerner.homeip.net]
* free for non-commercial use.
*
* Version 2012-01-15 WORKING
*/
#ifndef Button_h
#define Button_h
#include <Arduino.h>
class Button {
private:
int pin;
boolean lastStatus;
boolean recentStatus;
boolean changeFlag;
byte confidenceLevel; // 0-5 for debouncing, 0 no confidence, 5 max confidence
long int lastPulseWidth;
long int pulseStartMillis;
long int pulseEndMillis;
public:
Button(int newPin); // constructor
Button(int newPin,boolean pullup);
~Button(); // destructor
byte getPin();
void enablePullup();
void disablePullup();
boolean isPressed();
boolean isChanged();
unsigned long getPulseWidth();
void update();
};
#endif
and my Led.h
/* Simple LED Class for Arduino 1.x by Axel Werner [mail@awerner.homeip.net]
* free for non-commercial use.
*
* Version 2012-01-15 WORKING
*/
#ifndef Led_h
#define Led_h
#include <Arduino.h>
class Led {
private:
byte pin;
byte ledMode; // Valid: 1-3 : 1-Static, 2-Blinky, 3-Flashy
boolean lastStatus;
unsigned int blinkIntervall;
unsigned int flashDuration;
unsigned long lastToggleMillis;
unsigned long lastIntevallMillis;
void doBlinky();
void doFlashy();
void on();
void off();
public:
// Led(byte newPin,boolean defaultStatus);
Led(byte newPin); // constructor
~Led(); // destructor
void update();
void toggle();
byte getPin();
byte getMode();
void setOn();
void setOff();
void setMode(byte newMode);
void setFlash(int intervall,int newFlashDuration);
void setBlink(int intervall);
};
#endif