can i used arduino library on atmega8?

You should (and probably want to) stay away from the old "Arduino NG and older" option. It was originally made for boards without auto reset, so there's a 10 second delay from hitting reset until you program starts. The bootloader is significantly larger than Optiboot, and there aren't a lot of space.

All very true IF the Op intends on using a bootloader. For device with such scant resources, I would use ISP.

Ray