Skip to: Site menu | Main content


Welcome to PSP-Programming.com, a place for developers to get together.

Welcome to the forums. Here you can find other user tutorials as well as homebrew releases and the source code repository. You can also ask for help with your code here and post your own homebrew!

PSP-Programming.com Forums
February 11, 2012, 01:03:28 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

News: Join our IRC channel: ##psp-programming on freenode
Home Help Search Shop Login Register
Digg This!
Pages: [1]
Print
Author Topic: Problem compiling code  (Read 532 times)
ps7sdk
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 2
637.01 points

View Inventory
Send Money to ps7sdk

View Profile
« on: June 09, 2011, 10:57:12 AM »

Could anyone say what is the problem with my code?
main.cpp
Code:
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <pspdisplay.h>
#include <malloc.h>
#include <SDL/SDL.h>
PSP_MODULE_INFO("Hello World", 0, 1, 1);
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common)
{
          sceKernelExitGame();
          return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp)
{
          int cbid;

          cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
          sceKernelRegisterExitCallback(cbid);

          sceKernelSleepThreadCB();

          return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
          int thid = 0;

          thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
          if(thid >= 0)
  {
                    sceKernelStartThread(thid, 0, 0);
          }

          return thid;
}


int main( int argc, char* args[] )

  pspDebugScreenInit();
  SetupCallbacks();
  //The images
  SDL_Surface* hello = NULL;
  SDL_Surface* screen = NULL;
  //Start SDL
  SDL_Init( SDL_INIT_EVERYTHING );
  //Set up screen
  screen = SDL_SetVideoMode( 320, 240, 32, SDL_SWSURFACE );
  //Load image
  hello = SDL_LoadBMP( "psp.bmp" );
  //Apply image to screen
  SDL_BlitSurface( hello, NULL, screen, NULL );
  //Update Screen
  SDL_Flip( screen );
  //Pause
  SDL_Delay( 2000 );
  //Free the loaded image
  SDL_FreeSurface( hello );
  //Quit SDL
  SDL_Quit();
  sceKernelSleepThread();
  return 0;
}


Makefile
Code:
TARGET = main
OBJS = main.o
INCDIR =
CFLAGS = -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LDFLAGS =
LIBS= -lpspgum -lpspgu -lm -lsdl

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = SDL Sample

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

doing "make" in command prompt give me a nice(!?) error.
Code:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\SDL_PSP>make
psp-gcc -I. -IC:/pspdev/psp/sdk/include -G0 -Wall -D_PSP_FW_VERSION=150  -L. -LC
:/pspdev/psp/sdk/lib   main.o -lpspgum -lpspgu -lm -lsdl -lpspdebug -lpspdisplay
 -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_r
esolver -lpsputility -lpspuser -lpspkernel -o main.elf
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspaudio.o):
 In function `PSPAUD_CloseAudio':
src/audio/psp/SDL_pspaudio.c:134: undefined reference to `sceAudioChRelease'
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspaudio.o):
 In function `PSPAUD_PlayAudio':
src/audio/psp/SDL_pspaudio.c:120: undefined reference to `sceAudioOutputPannedBl
ocking'
src/audio/psp/SDL_pspaudio.c:118: undefined reference to `sceAudioOutputBlocking
'
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspaudio.o):
 In function `PSPAUD_OpenAudio':
src/audio/psp/SDL_pspaudio.c:194: undefined reference to `sceAudioChReserve'
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspvideo.o):
 In function `PSP_GuStretchBlit':
src/video/psp/SDL_pspvideo.c:629: undefined reference to `sceGuStart'
src/video/psp/SDL_pspvideo.c:630: undefined reference to `sceGuEnable'
src/video/psp/SDL_pspvideo.c:631: undefined reference to `sceGuTexMode'
src/video/psp/SDL_pspvideo.c:632: undefined reference to `sceGuTexFunc'
src/video/psp/SDL_pspvideo.c:633: undefined reference to `sceGuTexFilter'
src/video/psp/SDL_pspvideo.c:634: undefined reference to `sceGuTexImage'
src/video/psp/SDL_pspvideo.c:635: undefined reference to `sceGuTexSync'
src/video/psp/SDL_pspvideo.c:672: undefined reference to `sceGuDrawArray'
src/video/psp/SDL_pspvideo.c:639: undefined reference to `sceGuGetMemory'
src/video/psp/SDL_pspvideo.c:647: undefined reference to `sceGuTexImage'
src/video/psp/SDL_pspvideo.c:649: undefined reference to `sceGuTexSync'
src/video/psp/SDL_pspvideo.c:676: undefined reference to `sceGuFinish'
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspvideo.o):
 In function `PSP_FlipHWSurface':
src/video/psp/SDL_pspvideo.c:558: undefined reference to `sceGuSwapBuffers'
src/video/psp/SDL_pspvideo.c:551: undefined reference to `sceGuSync'
src/video/psp/SDL_pspvideo.c:558: undefined reference to `sceGuSwapBuffers'
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspvideo.o):
 In function `PSP_GuUpdateRects':
src/video/psp/SDL_pspvideo.c:734: undefined reference to `sceGuSync'
src/video/psp/SDL_pspvideo.c:734: undefined reference to `sceGuSync'
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspvideo.o):
 In function `PSP_FillHWRect':
src/video/psp/SDL_pspvideo.c:688: undefined reference to `sceGuStart'
src/video/psp/SDL_pspvideo.c:690: undefined reference to `sceGuGetMemory'
src/video/psp/SDL_pspvideo.c:697: undefined reference to `sceGuDrawBuffer'
src/video/psp/SDL_pspvideo.c:701: undefined reference to `sceGuColor'
src/video/psp/SDL_pspvideo.c:702: undefined reference to `sceGuDrawArray'
src/video/psp/SDL_pspvideo.c:704: undefined reference to `sceGuDrawBuffer'
src/video/psp/SDL_pspvideo.c:706: undefined reference to `sceGuFinish'
src/video/psp/SDL_pspvideo.c:707: undefined reference to `sceGuSync'
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspvideo.o):
 In function `HWAccelBlit':
src/video/psp/SDL_pspvideo.c:587: undefined reference to `sceGuStart'
src/video/psp/SDL_pspvideo.c:589: undefined reference to `sceGuCopyImage'
src/video/psp/SDL_pspvideo.c:595: undefined reference to `sceGuFinish'
src/video/psp/SDL_pspvideo.c:599: undefined reference to `sceGuSync'
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspvideo.o):
 In function `PSP_SetColors':
src/video/psp/SDL_pspvideo.c:759: undefined reference to `sceGuStart'
src/video/psp/SDL_pspvideo.c:760: undefined reference to `sceGuClutLoad'
src/video/psp/SDL_pspvideo.c:761: undefined reference to `sceGuFinish'
src/video/psp/SDL_pspvideo.c:762: undefined reference to `sceGuSync'
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspvideo.o):
 In function `PSP_VideoQuit':
src/video/psp/SDL_pspvideo.c:777: undefined reference to `sceGuTerm'
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspvideo.o):
 In function `PSP_SetVideoMode':
src/video/psp/SDL_pspvideo.c:250: undefined reference to `sceGuInit'
src/video/psp/SDL_pspvideo.c:251: undefined reference to `sceGuStart'
src/video/psp/SDL_pspvideo.c:252: undefined reference to `sceGuDispBuffer'
src/video/psp/SDL_pspvideo.c:257: undefined reference to `sceGuDrawBuffer'
src/video/psp/SDL_pspvideo.c:259: undefined reference to `sceGuClear'
src/video/psp/SDL_pspvideo.c:260: undefined reference to `sceGuOffset'
src/video/psp/SDL_pspvideo.c:261: undefined reference to `sceGuViewport'
src/video/psp/SDL_pspvideo.c:262: undefined reference to `sceGuScissor'
src/video/psp/SDL_pspvideo.c:263: undefined reference to `sceGuEnable'
src/video/psp/SDL_pspvideo.c:264: undefined reference to `sceGuFrontFace'
src/video/psp/SDL_pspvideo.c:266: undefined reference to `sceGuFinish'
src/video/psp/SDL_pspvideo.c:267: undefined reference to `sceGuSync'
src/video/psp/SDL_pspvideo.c:270: undefined reference to `sceGuDisplay'
src/video/psp/SDL_pspvideo.c:254: undefined reference to `sceGuClutMode'
src/video/psp/SDL_pspvideo.c:255: undefined reference to `sceGuDrawBuffer'
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspevents.o)
: In function `PSP_EventQuit':
src/video/psp/SDL_pspevents.c:274: undefined reference to `pspIrKeybFinish'
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspevents.o)
: In function `PSP_EventInit':
src/video/psp/SDL_pspevents.c:247: undefined reference to `pspIrKeybInit'
src/video/psp/SDL_pspevents.c:249: undefined reference to `pspIrKeybOutputMode'
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspevents.o)
: In function `PSP_PumpEvents':
src/video/psp/SDL_pspevents.c:112: undefined reference to `pspIrKeybReadinput'
c:/pspdev/bin/../lib/gcc/psp/4.3.5/../../../../psp/lib\libsdl.a(SDL_pspevents.o)
: In function `EventUpdate':
src/video/psp/SDL_pspevents.c:71: undefined reference to `sceHprmPeekCurrentKey'

make: *** [main.elf] Error 1

C:\SDL_PSP>

Errr Evil or Very Mad Evil or Very Mad Crying or Very sad Crying or Very sad Crying or Very sad.....That was my first helloworld SDL for PSP.Plz help me.
Logged


mowglisanu

C/C++ Developer
Hero Member
*

Karma: +36/-11
Offline Offline

Posts: 787
0.00 points

View Inventory
Send Money to mowglisanu


View Profile
« Reply #1 on: June 09, 2011, 12:17:08 PM »

You're missing a bunch of libs in your makefile and the ones you have are out of order.
I suggest using sdl-config
Logged

Check out my:
 Audio lib
 Pmf Viewer
ps7sdk
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 2
637.01 points

View Inventory
Send Money to ps7sdk

View Profile
« Reply #2 on: June 14, 2011, 01:16:25 AM »

Here is my updated main.cpp
Code:
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <pspdisplay.h>
#include <malloc.h>
#include <SDL/SDL.h>

/* Exit callback */
int exit_callback(int arg1, int arg2, void *common)
{
          sceKernelExitGame();
          return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp)
{
          int cbid;

          cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
          sceKernelRegisterExitCallback(cbid);

          sceKernelSleepThreadCB();

          return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
          int thid = 0;

          thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
          if(thid >= 0)
  {
                    sceKernelStartThread(thid, 0, 0);
          }

          return thid;
}


int main(int argc, char *args[])

  pspDebugScreenInit();
  SetupCallbacks();
  //The images
  SDL_Surface* hello = NULL;
  SDL_Surface* screen = NULL;
  //Start SDL
  SDL_Init( SDL_INIT_EVERYTHING );
  //Set up screen
  screen = SDL_SetVideoMode( 320, 240, 32, SDL_SWSURFACE );
  //Load image
  hello = SDL_LoadBMP( "psp.bmp" );
  //Apply image to screen
  SDL_BlitSurface( hello, NULL, screen, NULL );
  //Update Screen
  SDL_Flip( screen );
  //Pause
  SDL_Delay( 2000 );
  //Free the loaded image
  SDL_FreeSurface( hello );
  //Quit SDL
  SDL_Quit();
  sceKernelSleepThread();
  return 0;
}


And the makefile updated as well
Code:
TARGET = main.cpp
OBJS = main.o
INCDIR =
PSPSDK = C:/pspsdk/psp/sdk
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LDFLAGS =


EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = SDL Sample

PSPSDK=$(shell psp-config --pspsdk-path)

PSPBIN = $(PSPSDK)/../bin
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
LIBS += $(shell $(PSPBIN)/sdl-config --libs)
include $(PSPSDK)/lib/build.mak

And the error
Code:
/usr/local/pspdev/psp/lib/libSDLmain.a(SDL_psp_main.o): In function `main':
psp/SDL_psp_main.c:86: undefined reference to `SDL_main'
collect2: ld returned 1 exit status
make: *** [main.cpp.elf] Error 1

Any idea why makefile does not find sdl_main?How I gonna do with it?
Logged
mowglisanu

C/C++ Developer
Hero Member
*

Karma: +36/-11
Offline Offline

Posts: 787
0.00 points

View Inventory
Send Money to mowglisanu


View Profile
« Reply #3 on: June 14, 2011, 02:49:02 PM »

You don't have an SDL_main, rename your main to SDL_main
Logged

Check out my:
 Audio lib
 Pmf Viewer
Pages: [1]
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.216 seconds with 31 queries.
Sister Sites: Guitar Hero 4   BrokeniTouch.com