Help: problem with pointers??

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

Moderators: cheriff, TyRaNiD

Post Reply
chutia
Posts: 2
Joined: Thu Nov 29, 2007 12:30 pm

Help: problem with pointers??

Post by chutia »

hi guys, need help I get this compiler error with this simple code :


Code: Select all

$ make
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   main.o  -lpspdebug -lpspdisplay -lpsp
ge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolve
r -lpsputility -lpspuser -lpspkernel -o temp.elf
main.o: In function `main':
main.c:(.text+0x88): undefined reference to `initGraphics'
main.o:(.rodata.sceModuleInfo+0x24): undefined reference to `__lib_ent_top'
main.o:(.rodata.sceModuleInfo+0x28): undefined reference to `__lib_ent_bottom'
main.o:(.rodata.sceModuleInfo+0x2c): undefined reference to `__lib_stub_top'
main.o:(.rodata.sceModuleInfo+0x30): undefined reference to `__lib_stub_bottom'
collect2: ld returned 1 exit status
make: *** [temp.elf] Error 1

Code: Select all

#include <pspdisplay.h>
#include <pspdebug.h>
#include <pspkernel.h>
#include <time.h>

PSP_MODULE_INFO&#40;"temp", 0, 1, 1&#41;;

#define printf pspDebugScreenPrintf
/*int displayimg&#40;int xcor, int ycor&#41;
int pollinput&#40;int* xtemp, int* ytemp&#41;*/

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
          sceKernelExitGame&#40;&#41;;
          return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
          int cbid;
          cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
          sceKernelRegisterExitCallback&#40;cbid&#41;;
          sceKernelSleepThreadCB&#40;&#41;;
          return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41; &#123;
          int thid = 0;
          thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
          if&#40;thid >= 0&#41; &#123;
                    sceKernelStartThread&#40;thid, 0, 0&#41;;
          &#125;
          return thid;
&#125;

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

	SetupCallbacks&#40;&#41;;
	pspDebugScreenInit&#40;&#41;;
	initGraphics&#40;&#41;;
	
	int  x, temp1, temp2;
	int *z;
	int *y;
	
	temp1 = 1;
	temp1 = 2;
	
	y = &temp1;
	z = &temp2;
	
	while&#40;1&#41;
	&#123;
		pspDebugScreenClear&#40;&#41;;
		
		tempFunc&#40;temp1, temp2&#41;;
			
		printf&#40;"temp1 value is %i ", *y&#41;;
		
		sleep&#40;1&#41;;
		for&#40;x=0; x<5; x++&#41;
		&#123;
			sceDisplayWaitVblankStart&#40;&#41;;
		&#125;
			
	&#125;
		
	sceKernelSleepThread&#40;&#41;;
	return 0;
&#125;

void tempFunc&#40;int *a, int* b&#41;
&#123;
	*a = *a + *b

&#125;

Code: Select all

TARGET = temp
OBJS = main.o 

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

LIBDIR =

LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = TEMP

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
I have searched previous posts without success.
Might be a problem with the make file??
terryxq
Posts: 16
Joined: Wed Oct 12, 2005 9:27 pm

Post by terryxq »

There is no definition & implement of the function "initGraphics" in your main.c but you called it.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

You've clearly been looking at tutorial that use graphics.c and graphics.h, but have forgotten to include those in your project. At the least, put those two files in your project folder and add graphics.o to the OBJS list.
chutia
Posts: 2
Joined: Thu Nov 29, 2007 12:30 pm

Post by chutia »

thanks for the reply guys,
firstly the make file was correct but in the c file there were lots of little mistakes I made, like not deleting the initgraphics(), sending the wrong variables to the function etc.
I have only been programming in C for a little while and just started on the psp this week.I think this explains it ;)
Problems solved for now.... thanks again.
Post Reply