# AVR-GCC: Ports Undeclared when compiling

My Setup

I'm running Ubuntu 12.10, and I want to be able to use gcc and avrdude to compile and program my ATmega328.

Everything installed perfectly, no errors or warnings. I have not installed avrdude yet, but that is beside the point.

I use the command:

avr-gcc -O0 -c blink_1MHz.c -o main.o

However, I get one warning, and many errors:

warning "device type not defined"

error: 'PORTC' undeclared (first use in this function)


The error above repeats itself for each Port and each Data Direction Register used in the code.

blink_1MHz.c is just some simple code I'm using to test my setup. It has worked on my Windows setup through AVR Studio 6.

I've tried Google, but the only real suggestion I got was to import the libraries:

#include <avr/io.h>
#include <stdlib.h>
#include <stdint.h>


Unfortunately, still nothing. I've been playing around with this for a while and I'm simply stumped. I saw suggestions that avr-libc isn't installed, but I have installed avr-libc. I would think that if I didn't have it installed, I would be seeing complaints about the libraries not existing.

Question

Could an enlightened individual suggest what may be the cause of these errors? Thanks.

EDIT

Amoch pointed out that I needed to check out avr/io.h; there you will see that you need to define the processor with the -mmcu flag. In my case, I have an ATmega328, so my command looked like:

avr-gcc -O0 -c blink_1MHz.c -mmcu=atmega328 -o main.o

• It is bad practice to use screenshots for a pure text dump. When searched through Google these error messages will never be found and therefore renders the question to lower value for others. Although the question is answered now, it would be nice if you could reproduce the errors and paste them as normal text. It'll help other visitors. May 30, 2013 at 6:25
• You're right. I was just too lazy to type it out, and I wanted the comprehension of the screenshot. I edited the picture out and added some of the errors and warnings in text. May 30, 2013 at 14:07