EmbDev.net

Forum: ARM programming with GCC/GNU tools stdio.h


von Joe McCarron (Guest)


Rate this post
useful
not useful
when i build my project using printf or sprintf function i get the
errors shown below. I have included stdio.h file in my project using
#include <stdio.h>.
It seems I cant access functions in the stdio library.
The project builds successfully when sprintf or printf is removed

***** output window *************
Compiling: Empty.c arm-elf-gcc -c  -mcpu=arm7tdmi  -I. -gdwarf-2
-DROM_RUN  -Os -Wall -Wstrict-prototypes -Wcast-align -Wcast-qual
-Wimplicit  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs
-Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow
-Wstrict-prototypes -Wunused -Wa,-adhlns=Empty.lst  -std=gnu99 -MD -MP
-MF .dep/Empty.o.d Empty.c -o Empty.o
Empty.c: In function 'main':
Empty.c:121: warning: unused variable 'i'
Empty.c:121: warning: unused variable 'count'
Linking: Empty.elf
arm-elf-gcc  -mcpu=arm7tdmi  -I. -gdwarf-2 -DROM_RUN  -Os -Wall
-Wstrict-prototypes -Wcast-align -Wcast-qual -Wimplicit
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs
-Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow
-Wstrict-prototypes -Wunused -Wa,-adhlns=Empty.o  -std=gnu99 -MD -MP -MF
.dep/Empty.elf.d Empty.o Interrupts.o build/crt0.o  --output Empty.elf
-nostartfiles -Wl,-Map=Empty.map,--cref -lc  -lm -lc -lgcc
-Tbuild/LPC2106-ROM.ld
c:/winarm/bin/../lib/gcc/arm-elf/4.0.0/../../../../arm-elf/lib\libc.a(fr 
eer.o):
In function `_malloc_trim_r':
mallocr.c:(.text+0x48): undefined reference to `_sbrk_r'
mallocr.c:(.text+0x70): undefined reference to `_sbrk_r'
mallocr.c:(.text+0xb4): undefined reference to `_sbrk_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.0.0/../../../../arm-elf/lib\libc.a(ma 
kebuf.o):
In function `__smakebuf':
makebuf.c:(.text+0x44): undefined reference to `_fstat_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.0.0/../../../../arm-elf/lib\libc.a(ma 
llocr.o):
In function `_malloc_r':
mallocr.c:(.text+0x36c): undefined reference to `_sbrk_r'
mallocr.c:(.text+0x5cc): undefined reference to `_sbrk_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.0.0/../../../../arm-elf/lib\libc.a(st 
dio.o):
In function `__sread':
stdio.c:(.text+0x1c): undefined reference to `_read_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.0.0/../../../../arm-elf/lib\libc.a(st 
dio.o):
In function `__swrite':
stdio.c:(.text+0x78): undefined reference to `_lseek_r'
stdio.c:(.text+0x9c): undefined reference to `_write_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.0.0/../../../../arm-elf/lib\libc.a(st 
dio.o):
In function `__sseek':
stdio.c:(.text+0xc0): undefined reference to `_lseek_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.0.0/../../../../arm-elf/lib\libc.a(st 
dio.o):
In function `__sclose':
stdio.c:(.text+0xf8): undefined reference to `_close_r'
make.exe: *** [Empty.elf] Error 1

> Process Exit Code: 2

*********end of output window*************************

von Martin Thomas (Guest)


Rate this post
useful
not useful
Joe McCarron wrote:
> when i build my project using printf or sprintf function i get the
> errors shown below. I have included stdio.h file in my project using
> #include <stdio.h>.
> It seems I cant access functions in the stdio library.

These are not functions of the "stdio library" (libc.a) but functions
which are needed by the functions in the library to access the hardware
(i.e. print to uart or print to LCD). This is a FAQ, please search this
forum, read the WinARM-Readme, look into the newlib-lpc-source or the
"syscalls.c"-files in some of the examples of my collection.

Martin Thomas

von outer_space (Guest)


Rate this post
useful
not useful
Joe McCarron wrote:
> when i build my project using printf or sprintf function i get the
> errors shown below. I have included stdio.h file in my project using
> #include <stdio.h>.

Check out my post 10 posts down,  it has a simpler version of sprintf
and printf that takes around 3k space compared to stdio's 20k.

von Joe McCarron (Guest)


Rate this post
useful
not useful
Martin Thomas wrote:
> Joe McCarron wrote:
>> when i build my project using printf or sprintf function i get the
>> errors shown below. I have included stdio.h file in my project using
>> #include <stdio.h>.
>> It seems I cant access functions in the stdio library.
>
> These are not functions of the "stdio library" (libc.a) but functions
> which are needed by the functions in the library to access the hardware
> (i.e. print to uart or print to LCD). This is a FAQ, please search this
> forum, read the WinARM-Readme, look into the newlib-lpc-source or the
> "syscalls.c"-files in some of the examples of my collection.
>
> Martin Thomas

I'm sorry I still can not use stdio.h functions in my code and I dont
know why.

I did a search on FAQ in this forum and just came up with my posts and
a couple of others.

I've compared link scripts and make files between my project and
"lpc2106_hello_rs232_newlib" proj the but didnt see anything wrong.

I have built, downloaded and run succesfully the project
"lpc2106_hello_rs232_newlib" which I added sprintf function to
be sure it would still link and it was ok.

When I included the same #include files in my project I still got the
link
errors shown in my previous post.

Any suggestions appreciated.

Thanks
Joe

von Jim K. (ancaritha)


Rate this post
useful
not useful
http://en.mikrocontroller.net/topic/67145

Check out that post.  It should have all the info you require.

von Joe McCarron (Guest)


Rate this post
useful
not useful
Jim Kaz wrote:
> http://en.mikrocontroller.net/topic/67145
>
> Check out that post.  It should have all the info you require.

Thanks, guys, the stdio routines are working for me now.

I didnt know but read that each implementation of C needs
its own low level routines depending on the hardware.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.