stdio.h

Guest #1171788
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*************************
Guest #1171789
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
Guest #1171790
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.
Guest #1171791
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

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now