avr/io.h No such file or directory error when compiling using avr-gcc
I’m guessing you started with the toolchain Arduino put on your machine. 

Try explicitly including the header files on the include path with the -I switch. 

avr-gcc -mmcu=atmega328p -I /path/to/avr/include -o main.out main.c


Just search for the io.h file. It should be somewhere close by to where you found the compiler.