5

How to load avr/io.h header files in the gcc compiler..I'm using 12.04 version of Ubuntu..

When ever i run a AVR program this kind of error is generating

fatal error: avr/io.h: No such file or directory. compilation terminated."

user.dz
  • 47,137
  • 13
  • 140
  • 258
yashwanth
  • 81
  • 1
  • 2
  • 4

1 Answers1

15

try installing avr-libc and gcc-avr:

sudo apt-get install avr-libc gcc-avr

Then, to compile code for the AVR you need start by compiling it to an executable using: gcc-avr and then link it using avr-objcopy to create a hex file for the device:

avr-gcc -mmcu=atmegaX yourpgm.c -o yourpgm.elf

avr-objcopy -j .text -O ihex yourpgm.elf yourpgm.hex

Then, the hex file generated is the one to be installed on the device. You can use avrdude to import it. There are a lot more options that you can use for the compiler and linker, I suggest reading the man page for these tools; they are very helpful.

frank.b
  • 161
  • 1
  • 3