libjpeg problems

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

Moderators: cheriff, TyRaNiD

Post Reply
yargon
Posts: 5
Joined: Mon Jul 13, 2009 11:54 am

libjpeg problems

Post by yargon »

Hello, I was trying to load a JPEG image with libjpeg, the code compiles but the linker returns errors indicating that the functions were not found.

main.cpp:

Code: Select all

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

int load_jpeg_file&#40;FILE* f&#41;
&#123;
	if&#40;!f&#41;
		return 0;
	jpeg_error_mgr jerr;
	struct jpeg_decompress_struct cInfo;
	cInfo.err = jpeg_std_error&#40;&jerr&#41;;
	jpeg_create_decompress&#40;&cInfo&#41;;
	jpeg_stdio_src&#40;&cInfo, f&#41;;
	return 1;
&#125;
/* Define the module info section */
PSP_MODULE_INFO&#40;"Test", 0, 0, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER&#41;;

int main&#40;int argc, char* argv&#91;&#93;&#41;
&#123;
	return 0;
&#125;
linker:

Code: Select all

psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150  -L. -L/usr/local/pspdev/psp/sdk/lib -specs=/usr/local/pspdev/psp/sdk/lib/prxspecs -Wl,-q,-T/usr/local/pspdev/psp/sdk/lib/linkfile.prx   main.o /usr/local/pspdev/psp/sdk/lib/prxexports.o -lglut -lglu -lgl -lg -lpspvfpu -lpsprtc -lpsprtc_driver -lpspjpeg -ljpeg -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o test.elf
main.o&#58; In function `load_jpeg_file&#40;__sFILE*&#41;'&#58;
main.cpp&#58;&#40;.text+0x2c&#41;&#58; undefined reference to `jpeg_std_error&#40;jpeg_error_mgr*&#41;'
main.cpp&#58;&#40;.text+0x40&#41;&#58; undefined reference to `jpeg_CreateDecompress&#40;jpeg_decompress_struct*, int, unsigned int&#41;'
main.cpp&#58;&#40;.text+0x4c&#41;&#58; undefined reference to `jpeg_stdio_src&#40;jpeg_decompress_struct*, __sFILE*&#41;'
collect2&#58; ld returned 1 exit status
make&#58; *** &#91;test.elf&#93; Error 1
Whats the reason? I'm getting crazy with this error ...

Thanks.
psPea
Posts: 60
Joined: Sat Sep 01, 2007 12:51 pm

Post by psPea »

libjpeg is C
extern "C" anyone
jojojoris
Posts: 255
Joined: Sun Mar 30, 2008 4:06 am

Post by jojojoris »

psPea wrote:libjpeg is C
extern "C" anyone
Shouldn't that be in jpeglib.h???

(It isn't in there. I know)

Code: Select all

int main&#40;&#41;&#123;
     SetupCallbacks&#40;&#41;;
     makeNiceGame&#40;&#41;;
     sceKernelExitGame&#40;&#41;;
&#125;
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

jojojoris wrote:
psPea wrote:libjpeg is C
extern "C" anyone
Shouldn't that be in jpeglib.h???

(It isn't in there. I know)
If you change a .c to .cpp, you need to put extern "C" {} around the C functions in that file as well.
Post Reply