I'm trying for the first time to use Arduino Libraries (Servo.h & Servo.cpp in this case) in Eclipse IDE.
So far I've managed to compile and run Arduino code using this tutorial (I suppose many of you already know it).
The problem comes when I add the Servo.cpp and Servo.h files and try to run the program:
13:35:08 **** Incremental Build of configuration Release for project Servo ****
make all
arduinoEclipse/subdir.mk:268: warning: overriding commands for target `arduinoEclipse/wiring_pulse.o'
arduinoEclipse/subdir.mk:261: warning: ignoring old commands for target `arduinoEclipse/wiring_pulse.o'
Building file: ../ServoTest.cpp
Invoking: AVR C++ Compiler
avr-g++ -I"C:\arduino\arduinoEclipse" -Wall -Os -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -funsigned-char -funsigned-bitfields -fno-exceptions -mmcu=atmega328p -DF_CPU=1600000UL -MMD -MP -MF"ServoTest.d" -MT"ServoTest.o" -c -o "ServoTest.o" "../ServoTest.cpp"
Finished building: ../ServoTest.cpp
Building target: Servo.elf
Invoking: AVR C++ Linker
avr-g++ -Wl,-Map,Servo.map,--cref -mrelax -Wl,--gc-sections -mmcu=atmega328p -o "Servo.elf" ./arduinoEclipse/CDC.o ./arduinoEclipse/HardwareSerial.o ./arduinoEclipse/HardwareSerial0.o ./arduinoEclipse/HardwareSerial1.o ./arduinoEclipse/HardwareSerial2.o ./arduinoEclipse/HardwareSerial3.o ./arduinoEclipse/IPAddress.o ./arduinoEclipse/PluggableUSB.o ./arduinoEclipse/Print.o ./arduinoEclipse/Servo.o ./arduinoEclipse/Stream.o ./arduinoEclipse/Tone.o ./arduinoEclipse/USBCore.o ./arduinoEclipse/WInterrupts.o ./arduinoEclipse/WMath.o ./arduinoEclipse/WString.o ./arduinoEclipse/abi.o ./arduinoEclipse/hooks.o ./arduinoEclipse/main.o ./arduinoEclipse/new.o ./arduinoEclipse/wiring.o ./arduinoEclipse/wiring_analog.o ./arduinoEclipse/wiring_digital.o ./arduinoEclipse/wiring_pulse.o ./arduinoEclipse/wiring_shift.o ./ServoTest.o
./ServoTest.o: In function `setup':
ServoTest.cpp:(.text.setup+0x8): undefined reference to `Servo::attach(int)'
./ServoTest.o: In function `loop':
ServoTest.cpp:(.text.loop+0x20): undefined reference to `Servo::writeMicroseconds(int)'
ServoTest.cpp:(.text.loop+0x5a): undefined reference to `Servo::writeMicroseconds(int)'
ServoTest.cpp:(.text.loop+0xbc): undefined reference to `Servo::write(int)'
./ServoTest.o: In function `_GLOBAL__sub_I_myservo':
ServoTest.cpp:(.text.startup._GLOBAL__sub_I_myservo+0x4): undefined reference to `Servo::Servo()'
collect2.exe: error: ld returned 1 exit status
make: *** [Servo.elf] Error 1
As you can see in the console output, it compiles correctly, but when it comes to the linker, it doesn't find the function references from the Servo.cpp.
As I have seen in this post, the problem comes from the fact that I need also to generate an .a (static library) file in order to link both .h and .cpp files. Still, I have no idea how I am supposed to generate this file.
For this project, I have just added in arduinoEclipse folder all the .cpp and .h files from C:\arduino\hardware\arduino\avr\cores\arduino
, C:\arduino\hardware\arduino\avr\variants\standard
& C:\arduino\libraries\Servo
.
Do you see what I could be missing?
Thank you in advance