Problem with LEONARDO and SevoTimer2 library

I am not able to compile any sketches referencing ServerTimer2 library when LEONARDO board is selected.

Here is a sample code.

#include <ServoTimer2.h>
ServoTimer2 a;
void setup()
{
   a.attach(5);
}
void loop()
{
  a.write(1500);
}

And the error message is:

C:\Autopilot\Arduino\arduino-105\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega32u4 -DF_CPU=16000000L -MMD -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DARDUINO=105 -IC:\Autopilot\Arduino\arduino-105\hardware\arduino\cores\arduino -IC:\Autopilot\Arduino\arduino-105\hardware\arduino\variants\leonardo -IC:\Users\User1\Documents\Arduino\libraries\ServoTimer2 C:\Users\User1\AppData\Local\Temp\build2195581623929243517.tmp\sketch_jan11a.cpp -o C:\Users\User1\AppData\Local\Temp\build2195581623929243517.tmp\sketch_jan11a.cpp.o 
In file included from sketch_jan11a.ino:1:
C:\Users\User1\Documents\Arduino\libraries\ServoTimer2/ServoTimer2.h:3:1: warning: "/*" within comment
C:\Autopilot\Arduino\arduino-105\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega32u4 -DF_CPU=16000000L -MMD -DUSB_VID=0x2341 -DUSB_PID=0x8036 -DARDUINO=105 -IC:\Autopilot\Arduino\arduino-105\hardware\arduino\cores\arduino -IC:\Autopilot\Arduino\arduino-105\hardware\arduino\variants\leonardo -IC:\Users\User1\Documents\Arduino\libraries\ServoTimer2 -IC:\Users\User1\Documents\Arduino\libraries\ServoTimer2\utility C:\Users\User1\Documents\Arduino\libraries\ServoTimer2\ServoTimer2.cpp -o C:\Users\User1\AppData\Local\Temp\build2195581623929243517.tmp\ServoTimer2\ServoTimer2.cpp.o 
In file included from C:\Users\User1\Documents\Arduino\libraries\ServoTimer2\ServoTimer2.cpp:15:
C:\Users\User1\Documents\Arduino\libraries\ServoTimer2\/ServoTimer2.h:3:1: warning: "/*" within comment
C:\Users\User1\Documents\Arduino\libraries\ServoTimer2\ServoTimer2.cpp:31: warning: 'TIMER2_OVF_vect' appears to be a misspelled signal handler
C:\Users\User1\Documents\Arduino\libraries\ServoTimer2\ServoTimer2.cpp: In function 'void TIMER2_OVF_vect()':
C:\Users\User1\Documents\Arduino\libraries\ServoTimer2\ServoTimer2.cpp:36: error: 'TCNT2' was not declared in this scope
C:\Users\User1\Documents\Arduino\libraries\ServoTimer2\ServoTimer2.cpp:46: error: 'TCNT2' was not declared in this scope
C:\Users\User1\Documents\Arduino\libraries\ServoTimer2\ServoTimer2.cpp: In function 'void initISR()':
C:\Users\User1\Documents\Arduino\libraries\ServoTimer2\ServoTimer2.cpp:132: error: 'TCCR2A' was not declared in this scope
C:\Users\User1\Documents\Arduino\libraries\ServoTimer2\ServoTimer2.cpp:133: error: 'TCCR2B' was not declared in this scope
C:\Users\User1\Documents\Arduino\libraries\ServoTimer2\ServoTimer2.cpp:133: error: 'CS21' was not declared in this scope
C:\Users\User1\Documents\Arduino\libraries\ServoTimer2\ServoTimer2.cpp:134: error: 'TCNT2' was not declared in this scope

Any suggestions how to deal with this?

Thanks,
Nick

Looks like something is wrong with that library.

Try the standard Servo library and use .writeMicroseconds()

Thanks for the reply. Unfortunately I can't easily switch to another library since I am not referencing it directly. It is used by other libraries that manage I2C and sensor data. Note that this problem only exists when compiling sketches for Leonardo. With other boards everything works fine. Any other suggestions?

nikivan:
Note that this problem only exists when compiling sketches for Leonardo. With other boards everything works fine. Any other suggestions?

Ask the author of the library to update it to work on Leonardo or switch to an UNO.