Hello,
I have spending hours trying to understand this probem... no way for me, I get errors when the linker get all stuffs together. Here is my basic example:
Users/.../Documents/Arduino/libraries/Dictionary/src/Dictionary.h:580: multiple definition of `_ZN10Dictionary5jloadERK6Stringi'; /Users/bparis/zaza/build/sketch/myClass.cpp.o:/Users/bparis/Documents/Arduino/libraries/Dictionary/src/Dictionary.h:580: first defined here
collect2: error: ld returned 1 exit status
I understand that <Dictionary.h>
is called from program.cpp because of the #include "myClass.h"
then is called a second time when "myClass.h" is loaded from MyClass.cpp.
How to get rid of that ?
Thanks
Bernard
You shouldn't put a definitions of the functions and variables to the header file if you plan to include this header more than once. In that case you should to put you declarations in header file and definitions to .cpp file.
I don't understand what you mean because in my opinion the header file MyClass.h does contain only declarations.
A solution that is working is to put all (declarations + definitions) in the .h file and delete the .ccp related file, but is that THE right solution ?