can i used arduino library on atmega8?

There's also one more thing.. the Arduino IDE introduced a new ATmega8 related bug when v1.6 was released. You're actually not able to set fuses or burn the bootloader because avrdude except the ATmega8 to have an extended fuse, which it hasn't. I had to create a separate avrdude routine in the platform.txt file to get around this issue. No idea why it hasn't been fixed in the IDE yet..