I'm using GCC (CygWin) cross-compiling targeting an Arm7 processor. the problem is none of the standard library functions are available for my program. as I understand it, libc.a is the library i should be using. strangely, this file has been copied to the application source directory.
I would've thought if I did the following, I should be able to use these functions:
- have included (enclosed in <>) string.h and stdlib.h in my LCD.c file
- mention libc.a to the linker
During make, here's what it says:
$ make
.compiling
..linking
arm-elf-ld -v -Map main.map -nostartfiles -T simple.cmd -o main.out start.o ivt.
o main.o libc.a LCD.o
GNU ld version 2.14 20030612
LCD.o(.text+0x75c): In function `LCD_DispSmallDigits':
: undefined reference to `strlen'
LCD.o(.text+0x22d4): In function `LCD_DispSelMsgAt':
: undefined reference to `malloc'
LCD.o(.text+0x22e0): In function `LCD_DispSelMsgAt':
: undefined reference to `strcpy'
LCD.o(.text+0x2308): In function `LCD_DispSelMsgAt':
: undefined reference to `free'
LCD.o(.text+0x2358): In function `LCD_DispNumMsgAt':
: undefined reference to `malloc'
LCD.o(.text+0x2368): In function `LCD_DispNumMsgAt':
: undefined reference to `sprintf'
LCD.o(.text+0x2384): In function `LCD_DispNumMsgAt':
: undefined reference to `free'
the code I'm using is quite mundane:
void LCD_DispSelMsgAt(int iRow, int iCol, int bSelected, char* s)
{
int i;
char* sBuffer = (char*) malloc(100);
strcpy(sBuffer, s);
if (bSelected)
for (i=0; i<strlen(sBuffer); i++)
if ((*(sBuffer + i)>='a') && (*(sBuffer + i)<='z'))
*(sBuffer + i) = (*(sBuffer + i)) - 0x20;
LCD_DispMsgAt(iRow, iCol, sBuffer);
free(sBuffer);
}
how can I get access to those standard routines?
thank you!
PS: it seems to me I'm having quite a "general" problem so what I'm about to say is not central to this question but i'll mention it anyway...
I noticed something that specifically relates to strlen( ). the prototype for strlen( ) has the parameter as "const char* s". it seems then it works fine with:
i = strlen("abc")
but not in the code sample routine shown above. that wouldn't be a very helpful library routine that can't be used as strlen(char* s).
reply to @n.m.:
adding /gnude/arm-elf/lib/libc.a to the linker command line introduced a "thousand" errors.
$ make
..linking
arm-elf-ld -v -Map main.map -nostartfiles -T LinkerScript.cmd -L /gnude/arm-elf/
lib -o main.out start.o ivt.o main.o LCD.o /gnude/arm-elf/lib/libc.a
GNU ld version 2.14 20030612
/gnude/arm-elf/lib/libc.a(syscalls.o)(.text+0x714): In function `_sbrk':
: undefined reference to `end'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x8c0): In function `_vfprintf_r':
: undefined reference to `__eqdf2'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x1054): In function `_vfprintf_r':
: undefined reference to `__nedf2'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x155c): In function `_vfprintf_r':
: undefined reference to `__umoddi3'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x1578): In function `_vfprintf_r':
: undefined reference to `__udivdi3'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x1834): In function `_vfprintf_r':
: undefined reference to `__ltdf2'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x1d98): In function `cvt':
: undefined reference to `__eqdf2'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x1e10): In function `cvt':
: undefined reference to `__nedf2'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x1e30): In function `cvt':
: undefined reference to `__negdf2'
/gnude/arm-elf/lib/libc.a(dtoa.o)(.text+0x7c): In function `_dtoa_r':
: undefined reference to `__eqdf2'
not sure what i should do next. i think i'll start by removing the explicit libc.a from the linker command line.