| View previous topic :: View next topic |
| Author |
Message |
Thanhda

Joined: 09 Apr 2005 Posts: 331 Location: Canada
|
Posted: Tue Jul 26, 2005 10:59 am Post subject: odd c++ error |
|
|
alright, i've been looking around to see if people have had this same problem, and i've notice that people have. but no one really answers there question. my problem is that it cant seem to instantiate a new object into my main. basically i can create a class but when i type "testClass *test = new testClass" it doesnt seem to work. if i type "testClass *test;" it compiles. but cant access any of the members of the class.
heres what happens when i create a 'new' object
| Code: |
psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -fno-rtti -c -o main.o main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:40: warning: unused variable ‘TestObj’
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/pspdev/psp/sdk/lib main.o me.o -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspuser -lpspkernel -o mebasic.elf
main.o: In function `main':
main.cpp:(.text+0x18): undefined reference to `operator new(unsigned int)'
collect2: ld returned 1 exit status
make: *** [mebasic.elf] Error 1
|
i used the "me" demo to try this. also renamed the file to main.cpp
| Code: |
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <pspdisplay.h>
#include <stdlib.h>
#include <string.h>
/* Define the module info section */
PSP_MODULE_INFO("mebasic", 0, 1, 1);
/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(0);
/* Define printf, just to make typing easier */
#define printf pspDebugScreenPrintf
void me_run(void);
void me_end(void);
class testClass
{
public:
int num;
};
int main(int argc, char *argv[])
{
SceCtrlData ctl;
testClass* test = new TestClass;
pspDebugScreenInit();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);
/* Copy our small program into the ME reset vector */
//memcpy((void *)0xbfc00040, me_run, (int)(me_end - me_run));
sceKernelDcacheWritebackInvalidateAll();
sceSysregMeResetEnable();
sceSysregMeBusClockEnable();
sceSysregMeResetDisable();
sceSysregVmeResetDisable();
while(1)
{
volatile u32 *count = (u32*) 0xBFC00060;
pspDebugScreenSetXY(0, 0);
pspDebugScreenPrintf("ME Basic Example, press Home to exit\n");
sceKernelDcacheWritebackInvalidateAll();
pspDebugScreenPrintf("ME Counter: %08x\n", *count);
sceCtrlReadBufferPositive(&ctl, 1);
if(ctl.Buttons & PSP_CTRL_HOME)
{
sceKernelExitGame();
}
sceDisplayWaitVblankStart();
}
return 0;
}
|
the makefile if the same as it was default _________________ There are 10 types of people in the world: Those who understand binary, and those who don't... |
|
| Back to top |
|
 |
lantus

Joined: 10 May 2005 Posts: 10
|
Posted: Tue Jul 26, 2005 1:04 pm Post subject: |
|
|
things may have changed but try linking with -lstdc++ _________________ xSnes9x - Snes9x Emulation for Xbox Consoles |
|
| Back to top |
|
 |
Thanhda

Joined: 09 Apr 2005 Posts: 331 Location: Canada
|
Posted: Tue Jul 26, 2005 3:30 pm Post subject: |
|
|
get errors. when i compile it still. but this time even more.
| Code: |
[root@localhost basic]# psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/pspdev/psp/sdk/lib main.o me.o -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspuser -lpspkernel -lstdc++ -o mebasic.elf
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(eh_personality.o): In function `base_of_encoded_value':
/tmp/pspdev/gcc-4.0.1/libstdc++-v3/../gcc/unwind-pe.h:122: undefined reference to `abort'
/tmp/pspdev/gcc-4.0.1/libstdc++-v3/../gcc/unwind-pe.h:122: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(eh_personality.o): In function `read_encoded_value_with_base':
/tmp/pspdev/gcc-4.0.1/libstdc++-v3/../gcc/unwind-pe.h:259: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(eh_personality.o): In function `get_ttype_entry':
/tmp/pspdev/gcc-4.0.1/libstdc++-v3/../gcc/unwind-pe.h:90: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(eh_terminate.o):../../../../libstdc++-v3/libsupc++/eh_terminate.cc:44: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(eh_terminate.o):../../../../libstdc++-v3/libsupc++/eh_terminate.cc:46: more undefined references to `abort' follow
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:69: undefined reference to `fwrite'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:71: undefined reference to `fputs'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:74: undefined reference to `fwrite'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:73: undefined reference to `fputs'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:74: undefined reference to `fwrite'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:51: undefined reference to `fwrite'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:52: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:95: undefined reference to `fwrite'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:97: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:97: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:87: undefined reference to `fwrite'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:88: undefined reference to `fputs'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:89: undefined reference to `fputc'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(vterminate.o):../../../../libstdc++-v3/libsupc++/vterminate.cc:97: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(cp-demangle.o): In function `d_identifier':
cp-demangle.c:(.text+0x1538): undefined reference to `memcmp'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(cp-demangle.o): In function `d_print_resize':
cp-demangle.c:(.text+0x3e18): undefined reference to `realloc'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(cp-demangle.o): In function `d_demangle':
cp-demangle.c:(.text+0x8fd8): undefined reference to `strncmp'
cp-demangle.c:(.text+0x9268): undefined reference to `strcat'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libstdc++.a(cp-demangle.o): In function `__cxa_demangle':
cp-demangle.c:(.text+0x95d4): undefined reference to `strcpy'
/usr/local/pspdev/lib/gcc/psp/4.0.1/libgcc.a(unwind-dw2.o): In function `base_of_encoded_value':
../../gcc/unwind-pe.h:122: undefined reference to `abort'
../../gcc/unwind-pe.h:122: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.1/libgcc.a(unwind-dw2.o): In function `read_encoded_value_with_base':
../../gcc/unwind-pe.h:259: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.1/libgcc.a(unwind-dw2.o): In function `_Unwind_GetGR':
../../gcc/unwind-dw2.c:146: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.1/libgcc.a(unwind-dw2.o): In function `_Unwind_SetGR':
../../gcc/unwind-dw2.c:182: undefined reference to `abort'
/usr/local/pspdev/lib/gcc/psp/4.0.1/libgcc.a(unwind-dw2.o):../../gcc/unwind-dw2.c:947: more undefined references to `abort' follow
collect2: ld returned 1 exit status
|
_________________ There are 10 types of people in the world: Those who understand binary, and those who don't... |
|
| Back to top |
|
 |
cooleyandy
Joined: 02 Jul 2005 Posts: 41
|
Posted: Thu Jul 28, 2005 4:44 am Post subject: |
|
|
you might want to try reordering the libraries. This is what I used in my build.mak
# Link with following default libraries. Other libraries should be specified in the $(LIBS) variable.
# TODO: This library list needs to be generated at configure time.
PSPSDK_LIBS = -lpspdebug -lpsppower -lpspdisplay -lpspge -lpspctrl -lpspaudiolib -lpspaudio -lpspsdk
LIBS := -lstdc++ -lpng -lmad -lz -lm
LIBS := $(LIBS) $(PSPSDK_LIBS) $(PSPSDK_LIBC_LIB) -lpspuser -lpspkernel
just remove any of the psp libraries you don't use. |
|
| Back to top |
|
 |
|