Compiling Problems with sprintf? (PRX module)

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
jtwald
Posts: 24
Joined: Wed Jan 04, 2006 2:57 am

Compiling Problems with sprintf? (PRX module)

Post by jtwald »

when I comment out the lines in my PRX which I use sprintf - I don't receive this error.:

after it compiles, i nthe object linking stage:

Code: Select all

main.o In function 'displayCoordinates':
main.c:(.text+7c): undefined reference to '__extendsfdf2'
but i need to be able to use sprintf :/
I'm not sure what is wrong or have any idea what that error means.
adrahil
Posts: 274
Joined: Thu Mar 16, 2006 1:55 am

Post by adrahil »

did you link it to libc? (-lc)
show us your makefile...
jtwald
Posts: 24
Joined: Wed Jan 04, 2006 2:57 am

Post by jtwald »

adrahil wrote:did you link it to libc? (-lc)
show us your makefile...
I'm sorry, I should have posted it before:

Code: Select all

TARGET = PRXTest
OBJS = font.o main.o

BUILD_PRX=1

USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1

PRX_EXPORTS=exports.exp

INCDIR = 
CFLAGS = -Os -G0 -Wall -fno-strict-aliasing -fno-builtin-printf
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LDFLAGS = -nostdlib -nodefaultlibs
LIBS = -ldevhook -lpsppower

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
mbf
Posts: 55
Joined: Fri Aug 18, 2006 7:43 pm

Post by mbf »

You are using the kernel libc and sprintf is not included in it. You'll have to make your own sprintf.

Tip: grab the sources of newlib....
jtwald
Posts: 24
Joined: Wed Jan 04, 2006 2:57 am

Post by jtwald »

Would compiling it with xprintf.c from newlib work?
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

sprintf does exist in the kernel libc, what the real problem is you are converting floating point values around which isn't getting linked in (that function is part of libgcc it extends 32bit floats to doubles). However the kernel libc doesn't support float formatting anyway so I wouldn't bother continuing on that vein.
jtwald
Posts: 24
Joined: Wed Jan 04, 2006 2:57 am

Post by jtwald »

TyRaNiD wrote:sprintf does exist in the kernel libc, what the real problem is you are converting floating point values around which isn't getting linked in (that function is part of libgcc it extends 32bit floats to doubles). However the kernel libc doesn't support float formatting anyway so I wouldn't bother continuing on that vein.
So I need to use doubles? Or what is the fix for this...
jtwald
Posts: 24
Joined: Wed Jan 04, 2006 2:57 am

Post by jtwald »

I'm sorry, I now undrstand what you meant.

Hmph, that leaves me with no way to do what I wanted and plenty of wasted time.

Gotta love psp development :)
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Well not exactly, you could as suggested try and copy xprintf.c from the pspsdk libc and try and link it directly into your application, alternatively you could do what I did in psplink and write a simple float->string function and then only use sprintf to fomat a string not a float, it is admittedly more hassle but it might be your only way.

Incidently the functions it is missing for float conversion should be getting linked in, are you linking your app with gcc or going to ld directly ?
Post Reply