User forums > Embedded development

a problem compiling eeprom of avr(atmega16,winavr) program

(1/7) > >>

zage2009:
I used CB to compile the avr program which wrote and read eeprom inside avr(atmege16) and couldn't compile sucessfully.The compiler is winavr-20100110 and the optimization level is zero.The error messages were undefined reference to __eewr_byte_m16 and undefined reference to __eerd_byte_m16,but compiling it in avrstudio4.18 is sucessfully and works.here is the promgram:

--- Code: ---#include <avr/io.h>
#include <avr/eeprom.h>
void init(void);
void write_com(unsigned char com);
void write_data(unsigned char data);

int main(void)
{

    unsigned char i;
eeprom_busy_wait();
eeprom_write_byte(0x00,0x01);
eeprom_busy_wait();
i = eeprom_read_byte(0x00);
while(1);
}


--- End code ---

I really don't how to do.

MortenMacFly:

--- Quote from: zage2009 on August 03, 2011, 02:39:22 pm ---I really don't how to do.

--- End quote ---
Link against the libraries that provide these references in the right order. Consult the AVR SDK documentation which libs these are.

scarphin:
U have to add the library '(WinAVR path)\avr\lib\avr5\libc.a' to the 'link libraries' under 'project->build options->linker settings' for ur code to compile. It's quite strange though that the include file doesn't link to the corresponding library.

Jenna:

--- Quote from: scarphin on August 03, 2011, 06:03:27 pm ---U have to add the library '(WinAVR path)\avr\lib\avr5\libc.a' to the 'link libraries' under 'project->build options->linker settings' for ur code to compile. It's quite strange though that the include file doesn't link to the corresponding library.


--- End quote ---

How should an include file link to a library ?
As far as I know, this is not possible on gcc-based compilers.

scarphin:
Sry that wasn't what I wanted to mean. What I tried to say was I'm surprised why the library itself doesn't care of this. I mean how can the programmer know which compiled library to add after including an include file. I think I'm missing something here. Linking the file manually shouldn't be the way although it works. How does GCC manage this? I tried adding the path to the library to the 'linker search directories' in the compiler settings with no luck. ;/

Navigation

[0] Message Index

[#] Next page

Go to full version