Problems linking libc with GNUARM

Started by bmueller38 September 8, 2006
Hi everybody,

I am a newbie and I have problems using stdlib functions. I would like
to use sprintf() or itoa(), but the Linker is obviously not able to
use the corresponding libraries..

My linker command is the following:

arm-elf-ld -v -LC:\Programme\GNUARM\arm-elf\lib
-LC:\Programme\GNUARM\lib\gcc\arm-elf\4.1.0 -Map main.map -T
rotationspendel.cmd -o main.out crt.o main.o lpc2138init.o
functions.o -lc -lm -lg -lgcc -lgcov

And this is my error for sprintf():

C:\Programme\GNUARM\arm-elf\lib/libc.a(syscalls.o): In function `_sbrk':
../../../../../../newlib-1.14.0/newlib/libc/sys/arm/syscalls.c:500:
undefined reference to `end'

and for itoa():

/cygdrive/c/EclipseWS/Recover/main.c:103: undefined reference to `itoa'

Can anybody help me? Thanks.
bjoern

An Engineer's Guide to the LPC2100 Series

you need syscall function in your code to use the printf/scanf function in the newlib_lpc library. since thos library use malloc function you need to provide it.

look into this example this can probably answer your question. If you don,t need floating point, look for the rprintf instead that desn't require the syscall function.

http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/#gcc_stdio
JOnathan
----- Original Message -----
From: bmueller38
To: l...
Sent: Friday, September 08, 2006 1:17 PM
Subject: [lpc2000] Problems linking libc with GNUARM
Hi everybody,

I am a newbie and I have problems using stdlib functions. I would like
to use sprintf() or itoa(), but the Linker is obviously not able to
use the corresponding libraries..

My linker command is the following:

arm-elf-ld -v -LC:\Programme\GNUARM\arm-elf\lib
-LC:\Programme\GNUARM\lib\gcc\arm-elf\4.1.0 -Map main.map -T
rotationspendel.cmd -o main.out crt.o main.o lpc2138init.o
functions.o -lc -lm -lg -lgcc -lgcov

And this is my error for sprintf():

C:\Programme\GNUARM\arm-elf\lib/libc.a(syscalls.o): In function `_sbrk':
../../../../../../newlib-1.14.0/newlib/libc/sys/arm/syscalls.c:500:
undefined reference to `end'

and for itoa():

/cygdrive/c/EclipseWS/Recover/main.c:103: undefined reference to `itoa'

Can anybody help me? Thanks.
bjoern
>From: bmueller38
>I am a newbie and I have problems using stdlib functions. I would like
>to use sprintf() or itoa(), but the Linker is obviously not able to
>use the corresponding libraries..
>
>My linker command is the following:
>
>arm-elf-ld -v -LC:\Programme\GNUARM\arm-elf\lib
>-LC:\Programme\GNUARM\lib\gcc\arm-elf\4.1.0 -Map main.map -T
>rotationspendel.cmd -o main.out crt.o main.o lpc2138init.o
>functions.o -lc -lm -lg -lgcc -lgcov
>
>And this is my error for sprintf():
>
>C:\Programme\GNUARM\arm-elf\lib/libc.a(syscalls.o): In function `_sbrk':
>../../../../../../newlib-1.14.0/newlib/libc/sys/arm/syscalls.c:500:
>undefined reference to `end'

Your startup is not defining the symbol end apparently.

newlib-lpc has startup that will define the end symbol and provide stubs
for other I/O functions. I don't know how the GNUARM build of newlib is
done so I don't know if the stub implementation it uses will provide the
functionality you will want.

>and for itoa():

itoa is not a standard function

Robert
--------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .
>From: Jonathan Dumaresq
>you need syscall function in your code to use the printf/scanf function in
the newlib_lpc >library. since thos library use malloc function you need to
provide it.

I don't think GNUARM uses newlib-lpc and there is no evidence from the link
line that it does. newlib-lpc (http://www.aeolusdevelopment.com) is a
supplement to newlib to provide some of the hooks newlib cannot in general
provide itself.

>look into this example this can probably answer your question. If you
don,t need floating >point, look for the rprintf instead that desn't
require the syscall function.
>
>http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/#gcc_stdio

That example uses WINARM, which does include newlib-lpc.

Robert
--------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .
> >From: Jonathan Dumaresq
> >you need syscall function in your code to use the printf/scanf
function in
> the newlib_lpc >library. since thos library use malloc function you
need to
> provide it.
>
> I don't think GNUARM uses newlib-lpc and there is no evidence from
the link
> line that it does. newlib-lpc (http://www.aeolusdevelopment.com) is a
> supplement to newlib to provide some of the hooks newlib cannot in
general
> provide itself.
>
> >look into this example this can probably answer your question. If you
> don,t need floating >point, look for the rprintf instead that desn't
> require the syscall function.
> >
> >http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/#gcc_stdio
>
> That example uses WINARM, which does include newlib-lpc.
>
> Robert
>

So I have to implement the newlib-lpc functionality in my GNUARM
installation. Right?
How do I do that? I downloaded the newest release from
aeolusdevelopment.com but I am not really able to compile it :(
Has somebody done this already? Or might it be easier to change to
WinARM? Please help me.

bjoern