Hello
I created two libraries for myself, one for controlling a LCD user interface (LCDUI) and the other for controlling an RFID reader (EZ522).
LCDUI has one class, UI, and is made of two files, ui.h and ui.cpp.
EZ522 does also only have one class, RFID, and is made of two files EZ522.h and EZ522.cpp
While developing the libraries, I had the .h and .cpp files of both libraries in the same folder as a test program so I could easily test and debug the library.
Everything worked fine.
Then I put the h and cpp files of both libraries into a .zip file, added keywords.txt for syntax coloring, then I added the library in the IDE. Of course I replaced all the
#include "something.h"
by
#include <something.h>
.
I then restarted the IDE, reopened the sketch and, of course, no syntax coloring. I have no idea if I did a mistake in the keywords.txt file or if something wrong happened when adding the library, and if it could have something to do with my problem. (Who knows?)
Then I compiled the sketch and, guess what, it did not work at all. Despite everything worked perfectly when the files were in the same folder, the compiler insulted me with a ton of errors, like:
libraries\LCDUI\ui.cpp.o (symbol from plugin): In function `UI::getKeystroke()':
(.text+0x0): multiple definition of `UI::splash(char*, double, char*, int, int, bool, int)'
sketch\ui.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\LCDUI\ui.cpp.o (symbol from plugin): In function `UI::getKeystroke()':
(.text+0x0): multiple definition of `UI::splash(char*, double, char*, char*, int, char*, int, int, bool, int, int, bool, int)'
sketch\ui.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\LCDUI\ui.cpp.o (symbol from plugin): In function `UI::getKeystroke()':
(.text+0x0): multiple definition of `UI::prompt(char*, char*)'
sketch\ui.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\LCDUI\ui.cpp.o (symbol from plugin): In function `UI::getKeystroke()':
(.text+0x0): multiple definition of `UI::prompt(char*, double, char*, int, bool, int)'
sketch\ui.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\LCDUI\ui.cpp.o (symbol from plugin): In function `UI::getKeystroke()':
(.text+0x0): multiple definition of `UI::prompt(char*, double, char*, char*, int, char*, int, bool, int, int, bool, int)'
sketch\ui.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\LCDUI\ui.cpp.o (symbol from plugin): In function `UI::getKeystroke()':
(.text+0x0): multiple definition of `UI::input(char*, float, float, float, float, char*, int, bool, int)'
sketch\ui.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\LCDUI\ui.cpp.o (symbol from plugin): In function `UI::getKeystroke()':
(.text+0x0): multiple definition of `UI::inputRestricted(char*, int*, int, int, char*, int, bool, int)'
sketch\ui.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\LCDUI\ui.cpp.o (symbol from plugin): In function `UI::getKeystroke()':
(.text+0x0): multiple definition of `UI::inputRestricted(char*, float*, int, int, char*, int, bool, int)'
sketch\ui.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\LCDUI\ui.cpp.o (symbol from plugin): In function `UI::getKeystroke()':
(.text+0x0): multiple definition of `UI::menu(char*, char**, int*, int, int)'
sketch\ui.cpp.o (symbol from plugin):(.text+0x0): first defined here
libraries\LCDUI\ui.cpp.o (symbol from plugin): In function `UI::getKeystroke()':
(.text+0x0): multiple definition of `UI::inputChar(char*, char*, int)'
sketch\ui.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Erreur de compilation pour la carte Arduino Duemilanove or Diecimila
In my code, some functions are actually declared several times, like that:
void disp(char top [], char bottom [] = "");//Displays two char arrays, on the top and bottom lines of the display.
void disp(char title [], double value, char unit [] = "", int minDigits = 0, bool showDecimal = false, int base = DEC);
void disp(char topTitle [], double topValue, char topUnit [], char btmTitle [], int btmValue, char btmUnit [], int topMinDigits = 0, bool topShowDecimal = false, int topBase = DEC, int btmMinDigits = 0, bool btmShowDecimal = false, int btmBase = DEC);
But I don’t think this is the problem, because i have the
multiple definition of
for each and every function of both libraries.
I’ve googled this but i didn’t really understood anything of what I read because I’m not good at programming. Or I don’t have enough knowledge of C++ compiling and object oriented programming to understand it.
Any help would be greatly appreciated. Thanks in advance. I’m sure I made a stupid mistake…