"undefined reference to _sprintf_r" in latest tool

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

Moderators: cheriff, TyRaNiD

Post Reply
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

"undefined reference to _sprintf_r" in latest tool

Post by Shine »

When I compile this:

Code: Select all

#include <stdio.h>
#include <pspkernel.h>

/* Define the module info section */
PSP_MODULE_INFO&#40;"TEST", 0, 1, 1&#41;;

/* Define the main thread's attribute value &#40;optional&#41; */
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;

int main&#40;void&#41;
&#123;
	tmpnam&#40;""&#41;;

	return 0;
&#125;
with this Makefile:

Code: Select all

TARGET = test
OBJS = main.o

INCDIR = 
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

LIBDIR =
LDFLAGS =
LIBS = -lpsputility

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Test

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
I'll get this error:

Code: Select all

$ make
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall  -L. -L/usr/local/pspdev/psp/sdk/lib   main.o -lpsputility -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpsputility -lpspuser -lpspkernel -o test.elf
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libc.a&#40;tmpnam.o&#41;&#58; In function `worker'&#58;
../../../../../newlib/libc/stdio/tmpnam.c&#58;121&#58; undefined reference to `_sprintf_r'
collect2&#58; ld returned 1 exit status
make&#58; *** &#91;test.elf&#93; Error 1
Same error in Lua Player, which doesn't compile any more with the latest PSPSDK (or at least with my local environment, if this is the bug).
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Looks like tmpnam() is violating newlib conventions and calling _sprintf_r() (instead of sprintf()) directly. I'm currently out of town, when I get back Friday I can fix it if no one else gets to it by then.
Post Reply