building libpng

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

Moderators: cheriff, TyRaNiD

Post Reply
snowsquirrel
Posts: 51
Joined: Sun Feb 24, 2008 3:36 am

building libpng

Post by snowsquirrel »

I built libpng and libz using devkitPSP. They build fine.

I then tried to link them into my elf. I am getting link errors about fprintf (usually in stdio), pow (usually in math), longjmp (not sure about this one), and strtod (string).

My link command looks like this:

Code: Select all

psp-gcc -o build/debug/game.elf -specs=c:/devkitPSP/psp/sdk/lib/prxspecs -Wl,-q,-Tc:/devkitPSP/psp/sdk/lib/linkfile.prx c:/devkitPSP/psp/sdk/lib/prxexports.o build/debug/GameApp.o build/debug/GraphicsObject.o build/debug/main.o build/debug/Pad.o build/debug/graphics.o -Lc:/devkitPSP/psp/sdk/lib -Llibs/libpng -Llibs/zlib  -lstdc++ -lc -lpspgu -lpsprtc -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -lpng -lz 
And My output is this:

Code: Select all

libs/libpng\libpng.a(pngerror.o): In function `png_warning':
pngerror.c:(.text+0x1a0): undefined reference to `fprintf'
pngerror.c:(.text+0x218): undefined reference to `fprintf'
libs/libpng\libpng.a(pngerror.o): In function `png_error':
pngerror.c:(.text+0x304): undefined reference to `fprintf'
pngerror.c:(.text+0x310): undefined reference to `longjmp'
pngerror.c:(.text+0x37c): undefined reference to `fprintf'
pngerror.c:(.text+0x398): undefined reference to `fprintf'
libs/libpng\libpng.a(pngread.o): In function `png_create_read_struct_2':
pngread.c:(.text+0x1f20): undefined reference to `setjmp'
pngread.c:(.text+0x2054): undefined reference to `setjmp'
libs/libpng\libpng.a(pngrio.o): In function `png_default_read_data':
pngrio.c:(.text+0x8c): undefined reference to `fread'
libs/libpng\libpng.a(pngrtran.o): In function `png_build_gamma_table':
pngrtran.c:(.text+0x2c18): undefined reference to `pow'
pngrtran.c:(.text+0x2d08): undefined reference to `pow'
pngrtran.c:(.text+0x2e70): undefined reference to `pow'
pngrtran.c:(.text+0x2fd4): undefined reference to `pow'
pngrtran.c:(.text+0x30b0): undefined reference to `pow'
libs/libpng\libpng.a(pngrtran.o):pngrtran.c:(.text+0x319c): more undefined references to `pow' follow
libs/libpng\libpng.a(pngrutil.o): In function `png_handle_sCAL':
pngrutil.c:(.text+0x2254): undefined reference to `strtod'
pngrutil.c:(.text+0x2298): undefined reference to `strtod'
libs/libpng\libpng.a(pngrutil.o): In function `png_handle_sRGB':
pngrutil.c:(.text+0x38c8): undefined reference to `fprintf'
libs/libpng\libpng.a(pngrutil.o): In function `png_handle_cHRM':
pngrutil.c:(.text+0x3e90): undefined reference to `fprintf'
pngrutil.c:(.text+0x3f00): undefined reference to `fprintf'
libs/libpng\libpng.a(pngrutil.o): In function `png_handle_gAMA':
pngrutil.c:(.text+0x430c): undefined reference to `fprintf'
libs/libpng\libpng.a(pngwrite.o): In function `png_create_write_struct_2':
pngwrite.c:(.text+0x1354): undefined reference to `setjmp'
pngwrite.c:(.text+0x1424): undefined reference to `setjmp'
libs/libpng\libpng.a(pngwrite.o): In function `png_convert_from_time_t':
pngwrite.c:(.text+0x1574): undefined reference to `gmtime'
libs/libpng\libpng.a(pngwutil.o): In function `png_write_cHRM_fixed':
pngwutil.c:(.text+0x2054): undefined reference to `fprintf'
libs/libpng\libpng.a(pngwutil.o): In function `png_write_cHRM':
pngwutil.c:(.text+0x2294): undefined reference to `fprintf'
collect2: ld returned 1 exit status
I didn't think there was a fprintf? I thouth you had to use pspDebugPrintf()?

Thanks,
~S[/code]
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

Could you post your makefile?

Maybe your problem is just the linking order.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Looks like an order problem.

Code: Select all

-lpng -lz -lm -lstdc++
Those should be the last items in your LIBS line.
snowsquirrel
Posts: 51
Joined: Sun Feb 24, 2008 3:36 am

Post by snowsquirrel »

I am away from my dev computer right now, but I know I don't have libm listed, so I must be missing that. I already solved the stdio stuff, with order. , this should get the math stuff. Thanks witty.

Thanks for the help, I can tell this forum will be helpful.

BTW - I don't suppose libgmo has been ported over? It seems so much of the official stuff has 1:1 mappings, yet I can't find anything like gmo?

Thanks,

~Snow

ps - I don't use Makefiles. I use Rakefiles, as I am a ruby guy.
Post Reply