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

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."

1 Answer

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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like