Problem with USE_PSPSDK_LIBC = 1 and libpng

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

Moderators: cheriff, TyRaNiD

Post Reply
Tsukasa
Posts: 12
Joined: Mon Jul 04, 2005 6:28 am

Problem with USE_PSPSDK_LIBC = 1 and libpng

Post by Tsukasa »

Hi Guys :(

I've a difficult problem with my program.
I have to use the "USE_PSPSDK_LIBC = 1" tag in the makefile, but then, my libpng won't work :/

Here is the error message:

Code: Select all

$ make
psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk
/include -O2 -G0 -Wall  -L. -L/usr/local/pspdev/psp/sdk/lib   main.o -lpng -lz -
lm -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lpsplibc -lpspnet -lpspne
t_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o sc
reenshot.elf
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngerror.o): In
 function `png_warning':
pngerror.c:(.text+0x14c): undefined reference to `_impure_ptr'
pngerror.c:(.text+0x14c): relocation truncated to fit: R_MIPS_GPREL16 against `_
impure_ptr'
pngerror.c:(.text+0x1a8): undefined reference to `_impure_ptr'
pngerror.c:(.text+0x1a8): relocation truncated to fit: R_MIPS_GPREL16 against `_
impure_ptr'
pngerror.c:(.text+0x1ac): undefined reference to `_impure_ptr'
pngerror.c:(.text+0x1ac): relocation truncated to fit: R_MIPS_GPREL16 against `_
impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngerror.o): In
 function `png_error':
pngerror.c:(.text+0x2a8): undefined reference to `_impure_ptr'
pngerror.c:(.text+0x2a8): relocation truncated to fit: R_MIPS_GPREL16 against `_
impure_ptr'
pngerror.c:(.text+0x310): undefined reference to `_impure_ptr'
pngerror.c:(.text+0x310): relocation truncated to fit: R_MIPS_GPREL16 against `_
impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngerror.o):png
error.c:(.text+0x314): more undefined references to `_impure_ptr' follow
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngerror.o): In
 function `png_error':
pngerror.c:(.text+0x314): relocation truncated to fit: R_MIPS_GPREL16 against `_
impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngrutil.o): In
 function `png_handle_gAMA':
pngrutil.c:(.text+0xd08): relocation truncated to fit: R_MIPS_GPREL16 against `_
impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngrutil.o): In
 function `png_handle_cHRM':
pngrutil.c:(.text+0x1470): relocation truncated to fit: R_MIPS_GPREL16 against `
_impure_ptr'
pngrutil.c:(.text+0x14e0): relocation truncated to fit: R_MIPS_GPREL16 against `
_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngrutil.o): In
 function `png_handle_sRGB':
pngrutil.c:(.text+0x1790): relocation truncated to fit: R_MIPS_GPREL16 against `
_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngwrite.o): In
 function `png_convert_from_time_t':
pngwrite.c:(.text+0xac4): undefined reference to `gmtime'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngwutil.o): In
 function `png_write_cHRM':
pngwutil.c:(.text+0x1120): undefined reference to `_impure_ptr'
pngwutil.c:(.text+0x1120): additional relocation overflows omitted from the outp
ut
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngwutil.o): In
 function `png_write_cHRM_fixed':
pngwutil.c:(.text+0x16dc): undefined reference to `_impure_ptr'
collect2: ld returned 1 exit status
make: *** [screenshot.elf] Error 1
Can anyone help me :'(?
crazyc
Posts: 408
Joined: Fri Jun 17, 2005 10:13 am

Re: Problem with USE_PSPSDK_LIBC = 1 and libpng

Post by crazyc »

relocation truncated to fit: R_MIPS_GPREL16 against `_impure_ptr'

Libpng was not built with -G0.

undefined reference to `_impure_ptr'

It was built against newlib.
R2k
Posts: 16
Joined: Fri Mar 17, 2006 10:49 am
Location: México

i've the same problem

Post by R2k »

i'm compiling a program but when psp-gcc is linking displays this:

Code: Select all

$ make
psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk
/include -O2 -G0 -Wall -fno-strict-aliasing   -c -o main.o main.c
psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk
/include -O2 -G0 -Wall -fno-strict-aliasing   -c -o console.o console.c
psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk
/include -O2 -G0 -Wall -fno-strict-aliasing   -c -o common.o common.c
psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk
/include -O2 -G0 -Wall -fno-strict-aliasing   -c -o libs/framebuffer.o libs/fram
ebuffer.c
psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk
/include -O2 -G0 -Wall -fno-strict-aliasing   -c -o libs/graphics.o libs/graphic
s.c
psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk
/include -O2 -G0 -Wall -fno-strict-aliasing  -L. -L/usr/local/pspdev/psp/sdk/lib
   main.o console.o common.o libs/framebuffer.o libs/graphics.o -lpspgu -lpng -l
z -lm -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lpsplibc -lpspnet -lps
pnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o
 WArena+.elf
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngerror.o): En
 la función `png_warning':
pngerror.c:(.text+0x14c): referencia a `_impure_ptr' sin definir
pngerror.c:(.text+0x14c): reubicación truncada para ajustar: R_MIPS_GPREL16 cont
ra `_impure_ptr'
pngerror.c:(.text+0x1a8): referencia a `_impure_ptr' sin definir
pngerror.c:(.text+0x1a8): reubicación truncada para ajustar: R_MIPS_GPREL16 cont
ra `_impure_ptr'
pngerror.c:(.text+0x1ac): referencia a `_impure_ptr' sin definir
pngerror.c:(.text+0x1ac): reubicación truncada para ajustar: R_MIPS_GPREL16 cont
ra `_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngerror.o): En
 la función `png_error':
pngerror.c:(.text+0x2a8): referencia a `_impure_ptr' sin definir
pngerror.c:(.text+0x2a8): reubicación truncada para ajustar: R_MIPS_GPREL16 cont
ra `_impure_ptr'
pngerror.c:(.text+0x310): referencia a `_impure_ptr' sin definir
pngerror.c:(.text+0x310): reubicación truncada para ajustar: R_MIPS_GPREL16 cont
ra `_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngerror.o):png
error.c:(.text+0x314): más referencias a `_impure_ptr' sin definir a continuació
n
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngerror.o): En
 la función `png_error':
pngerror.c:(.text+0x314): reubicación truncada para ajustar: R_MIPS_GPREL16 cont
ra `_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngrutil.o): En
 la función `png_handle_gAMA':
pngrutil.c:(.text+0xd08): reubicación truncada para ajustar: R_MIPS_GPREL16 cont
ra `_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngrutil.o): En
 la función `png_handle_cHRM':
pngrutil.c:(.text+0x1470): reubicación truncada para ajustar: R_MIPS_GPREL16 con
tra `_impure_ptr'
pngrutil.c:(.text+0x14e0): reubicación truncada para ajustar: R_MIPS_GPREL16 con
tra `_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngrutil.o): En
 la función `png_handle_sRGB':
pngrutil.c:(.text+0x1790): reubicación truncada para ajustar: R_MIPS_GPREL16 con
tra `_impure_ptr'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngwrite.o): En
 la función `png_convert_from_time_t':
pngwrite.c:(.text+0xac4): referencia a `gmtime' sin definir
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngwutil.o): En
 la función `png_write_cHRM':
pngwutil.c:(.text+0x1120): referencia a `_impure_ptr' sin definir
pngwutil.c:(.text+0x1120): se omitieron desbordamientos de reubicación adicional
es de la salida
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngwutil.o): En
 la función `png_write_cHRM_fixed':
pngwutil.c:(.text+0x16dc): referencia a `_impure_ptr' sin definir
collect2: ld devolvi'o el estado de salida 1
make: *** [WArena+.elf] Error 1
my Makefile looks like this:

Code: Select all

TARGET = WArena+
OBJS = main.o console.o common.o libs/framebuffer.o libs/graphics.o

USE_PSPSDK_LIBC = 1

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

LIBDIR =
LDFLAGS = 

LIBS = -lpspgu -lpng -lz -lm

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = WArena+ 0.01 UMF

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
what could be happening

NOTE: the output is in spanish but all output is similar to the posted by Tsukasa
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

R2k: tienes el mismo problemo que esta passando
con Tsukasa ...el problema es que cuando tu make
libpng, la libreria no se construo come debe que ser

usted debe abrir el file Makefile en la directoria libpng
y cheqea que esta linia es exacto como debajo

CFLAGS = -O2 -G0

y guantar el file Makefile y vaz pa' tu cmd shell y
make y make install outra vez
10011011 00101010 11010111 10001001 10111010
R2k
Posts: 16
Joined: Fri Mar 17, 2006 10:49 am
Location: México

Post by R2k »

i checked the libpng's makefile and has the -O2 -G0
see:

Code: Select all

PSPSDK=$(shell psp-config --pspsdk-path)
PSPDIR=$(shell psp-config --psp-prefix)
TARGET_LIB = libpng.a
OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
	pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \
	pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o

CFLAGS = -O2 -G0

include $(PSPSDK)/lib/build.mak

install: $(TARGET_LIB)
	@echo "Installing libpng into $(PSPDIR)"
	@mkdir -p $(PSPDIR)/include $(PSPDIR)/lib
	@cp png.h pngconf.h $(PSPDIR)/include
	@cp libpng.a  $(PSPDIR)/lib
	@echo "Done"
but i did again the make , make install thing and the result is the same
R2k
Posts: 16
Joined: Fri Mar 17, 2006 10:49 am
Location: México

Post by R2k »

please someone help me this error is really pissing me off ...
PSP FW v2.6 owner
BlackDiamond
Posts: 16
Joined: Sat Jul 02, 2005 7:31 pm
Location: Paris, FRANCE

Post by BlackDiamond »

add "USE_PSPSDK_LIBC = 1" to libpng's makefile or type "make USE_PSPSDK_LIBC=1 install" (after running "make clean" of course)
danzel
Posts: 182
Joined: Fri Nov 04, 2005 11:03 pm

Post by danzel »

I'm going to say that libpng is compiled against newlib (as has been said) when you need to compile it against pspsdk-libc.

Try add:
USE_PSPSDK_LIBC = 1
To the makefile for libpng and compile+install it again.
(Don't know if this is enough)

Why do you need to use the pspsdk libc in the first place?

edit: just beaten ;)
R2k
Posts: 16
Joined: Fri Mar 17, 2006 10:49 am
Location: México

Post by R2k »

[POST DELETED BY MYSELF DUE A WEIRD THING HAPPENED WITH THE FORUM]
Last edited by R2k on Thu Mar 23, 2006 10:17 am, edited 1 time in total.
PSP FW v2.6 owner
R2k
Posts: 16
Joined: Fri Mar 17, 2006 10:49 am
Location: México

Post by R2k »

i added USE_PSPSDK_LIBC = 1 and the linking looks better but i'm still have a error in linking something about ... time.h and gmtime(...)

this is the output:

Code: Select all

psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk
/include -O2 -G0 -Wall  -L. -L/usr/local/pspdev/psp/sdk/lib   main.o console.o c
ommon.o libs/framebuffer.o libs/graphics.o -lpng -lz -lm -lpspgu -lpspdebug -lps
pdisplay -lpspge -lpspctrl -lpspsdk -lpsplibc -lpspnet -lpspnet_inet -lpspnet_ap
ctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o WArena.elf
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libpng.a(pngwrite.o): En
 la función `png_convert_from_time_t':
pngwrite.c:(.text+0xac4): referencia a `gmtime' sin definir
collect2: ld devolvi'o el estado de salida 1
make: *** [WArena.elf] Error 1 
Translation : "In function `png_convert_from_time_t':
pngwrite.c:(.text+0xac4): undefined reference to `gmtime'
collect2: ld returns exit status 1
make: *** [WArena.elf] Error 1 "

i'm using only to see the performance of old libs ... but i'm thinking in forgive this crazy stuff !!!
PSP FW v2.6 owner
User avatar
0xAVGP
Posts: 11
Joined: Sun Feb 05, 2006 3:28 am
Location: Burgwedel
Contact:

Post by 0xAVGP »

Anyone solved the problem?
I got this prob too...
the thing is: I got the Win32-Toolchain here, therefor: Has anyone a properly linked libpng for me :)
Thx in advance
Theory is, when nothing works and everybody knows that it should...

Pactic is, when everything works and nobody knows why...
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

I'd be tempted to just add a stub for gmtime().

Jim
User avatar
mcPhooey
Posts: 1
Joined: Thu Jul 31, 2008 11:58 pm
Location: UK

Post by mcPhooey »

It worked for me.

Using the current libpng version 1.2.8 and zlib 1.2.2

Inserted the line "USE_PSPSDK_LIBC = 1" into the makefiles of both libpng and zlib.

First in the zlib folder:
make clean
make
make install

Then in the libpng:
make clean
make
make install

Then make own project and all errors gone.
Post Reply