Error trying to upload a sketch on an ATmega328p bootloaded using Arduino IDE

Are you sure the bootloader is there? Also fuses have to be set correctly.