Hey there fellow programmers
I’m trying to break down the functions & objects related to the mechanical axes of a machine into separate .cpp/.h files (i’m breaking down a large sketch into a small one with external Cpp/h files actually).
To test this i’ve made a very simple test program.
My test program’s filetree is as follows :
library.h file #includes the
Servo Library, creates a
Servo instance and defines a prototype function to initialise it.
library.cpp file #includes the
library.h file and defines the initialisation function.
.ino file, finally, #includes the
library.h and tries to use the initialisation function.
However, when compiling I get the following error messages :
sketch/test_bug_arduino.ino.cpp.o (symbol from plugin): In function `setup': (.text+0x0): multiple definition of `servo0' sketch/library.cpp.o (symbol from plugin):(.text+0x0): first defined here collect2: error: ld returned 1 exit status exit status 1 Error compiling for board Arduino/Genuino Uno.
I guess i’m not doing things right, but I don’t know if it’s rather due to wrong code architecture or just noob programming.
I have attached the test sketch in an archive.
If anyone can help… Thanks
test_bug_arduino.zip (3.77 KB)