I am using Eclipse Helios for C/C++ and I have installed WinAvr which is installed at
C:\WinAVR-20100110.
I am trying to compile and link the following source:
------------------------------- test.c ---------------------------------
/*
- test.c
*/
#include <util/delay.h>
#include <avr/io.h>
#define LED PD4
int main(void) {
// define pd4 as output
DDRD |= (1 << LED);
while (1) {
PORTD |= (1 << LED); // switch on
_delay_ms(100);
_delay_ms(100);
PORTD &= ~(1 << LED); // switch off
_delay_ms(100);
_delay_ms(100);
}
return 0;
}
------------------------------------ end test.c ----------------------------------------------------
The source file compiles without issue however there is a linker problem.
Invoking: AVR Compiler
avr-gcc -Wall -g2 -gstabs -O0 -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega16u4 -DF_CPU=1000000UL -MMD -MP -MF"test.d" -MT"test.d" -c -o"test.o" “…/test.c”
Finished building: …/test.c
Building target: arduino.elf
Invoking: AVR C Linker
avr-gcc -Wl,-Map,arduino.map -mmcu=atmega16u4 -o"arduino.elf" ./test.o
c:/winavr-20100110/bin/…/lib/gcc/avr/4.3.3/…/…/…/…/avr/lib/avr5/crtm16u4.o:(.init9+0x0): undefined reference to `main’
make: *** [arduino.elf] Error 1
This is obviously a configuration problem. I am missing library or a path to a library.
How do i configure the paths in Eclipse?
black13.