Sorry for the incomplete question, this is the TEST.CPP file I've used:
Code: Select all
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* main.c - Basic PSPSDK sample.
*
* Copyright (c) 2005 Marcus R. Brown <[email protected]>
* Copyright (c) 2005 James Forshaw <[email protected]>
* Copyright (c) 2005 John Kelley <[email protected]>
*
* $Id: main.c 363 2005-06-27 20:35:14Z tyranid $
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <string.h>
class TestClass {
public:
int m_K;
};
/* Define the module info section */
PSP_MODULE_INFO("SDKTEST", 0, 1, 1);
/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
/* Define printf, just to make typing easier */
#define printf pspDebugScreenPrintf
extern "C" {
void dump_threadstatus(void);
/* Exit callback */
int exit_callback(void)
{
sceKernelExitGame();
return 0;
}
/* Callback thread */
void CallbackThread(void *arg)
{
int cbid;
printf("\nCallback Thread Status:\n");
dump_threadstatus();
cbid = sceKernelCreateCallback("Exit Callback", (void*)exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
}
/* Dump the current thread's status */
void dump_threadstatus(void)
{
int thid;
ThreadStatus status;
int ret;
thid = sceKernelGetThreadId();
memset(&status, 0, sizeof(ThreadStatus));
printf("Thread ID: %08X\n", thid);
status.size = sizeof(ThreadStatus);
ret = sceKernelReferThreadStatus(thid, &status);
printf("Get Thread Status: %08X\n", ret);
if(ret == 0)
{
printf("Name: %s\n", status.name);
printf("Thread Addr: %08X\n", status.th_addr);
printf("Stack Addr: %08X\n", status.stack_addr);
printf("Stack Size: %08X\n", status.stack_size);
printf("gp: %08X\n", status.gp);
printf("Initial Pri: %x\n", status.init_pri);
printf("Current Pri: %x\n", status.curr_pri);
}
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", (void*)CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int main(void)
{
pspDebugScreenInit();
printf("Bootpath: %s\n", g_elf_name);
SetupCallbacks();
printf("\nMain Thread Status:\n");
dump_threadstatus();
TestClass* TestObj = new TestClass;
TestObj->m_K = 1234;
delete TestObj;
sceKernelSleepThread();
return 0;
}
}
This is the makefile:
Code: Select all
TARGET = test
OBJS = test.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Test v1.0
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
also I've modified the build.mak from:
to
Code: Select all
PSPSDK_LIBC_LIB = -lpsplibc -lpspglue
when I tried to execute the makefile, this is what I get:
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/pspdev/psp/sdk/lib test.o -lpspdebug -lpsplibc -lpspglue -lpspkernel -o test.elf
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/crt0.o: In function `__entrytable':
crt0.S:(.rodata.sceResident+0xc): undefined reference to `module_info'
test.o: In function `main':
test.cpp:(.text+0x1fc): undefined reference to `operator new(unsigned int)'
test.cpp:(.text+0x20c): undefined reference to `operator delete(void*)'
collect2: ld returned 1 exit status
make: *** [test.elf] Error 1
I've read already the threads about problems in using the new and delete operators, tried several combinations of LIBS but so far no luck
Cheers,
Lev