can C++ be used with PSPSDK
-
- Posts: 41
- Joined: Sat Jul 02, 2005 10:12 am
can C++ be used with PSPSDK
I'm quite new to the psp dev scene and I must say, it piqued my interest in game programming. I have gotten the psptoolchain to run and I successfully compiled the 'sdktest' program. I've been wanting to port some old c++ programs that I have written but so far all my efforts to compiling any code (using 'make') with .cpp ends with an error that goes something like
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/crt0.o: In function `__e
ntrytable':
crt0.S:(.rodata.sceResident+0xc): undefined reference to `module_info'
I tried to rename the sdktest program's main.c to main.cpp and typed in 'make' to compile the program. That is how I got the error.
My background is from development using IDEs and basic command line compilations. This error baffles me, and I've been searching the forums for "c++" and came up with nothing. So after experimenting for a day and still coming up with nothing, I beseech the wise elder programmers of this forum for help. Any pointers besides "search the forums yourself" will be greatly appreciated.
/usr/local/pspdev/lib/gcc/psp/4.0.0/../../../../psp/lib/crt0.o: In function `__e
ntrytable':
crt0.S:(.rodata.sceResident+0xc): undefined reference to `module_info'
I tried to rename the sdktest program's main.c to main.cpp and typed in 'make' to compile the program. That is how I got the error.
My background is from development using IDEs and basic command line compilations. This error baffles me, and I've been searching the forums for "c++" and came up with nothing. So after experimenting for a day and still coming up with nothing, I beseech the wise elder programmers of this forum for help. Any pointers besides "search the forums yourself" will be greatly appreciated.
This error is fixed in Subversion, and it will be fixed in the next beta release (1.0+beta1, which will probably be released tonite or tomorrow).
The solution was also discussed here, so you must've missed this forum in your search :).
The solution was also discussed here, so you must've missed this forum in your search :).
-
- Posts: 41
- Joined: Sat Jul 02, 2005 10:12 am
Not using C++ and getting the error
I am not using C++, I am just using ansi-c.
I am just trying to compile:
Here is my make file:
Here is the output:
Please let me know if it's the same problem.
I am just trying to compile:
Code: Select all
#include <stdio.h>
int main() {
printf("Hello world");
while(1);
return 0;
}
Code: Select all
all:
psp-gcc -g -c Main.c
psp-gcc Main.o -o out -lpsplibc -lpspkernel -lpspdebug
elf2pbp out
Code: Select all
psp-gcc -g -c Main.c
psp-gcc Main.o -lpsplibc -lpspkernel -lpspdebug
../../../../psp/lib/crt0.o: In function `__entrytable':
crt0.S:(.rodata.sceResident+0xc): undefined reference to `module_info'
collect2: ld returned 1 exit status
make: *** [all] Error 1
Execution terminated
Lego of my Ago!
Actually it's not the same as the C++ extern issue and it's not a problem - you must have PSP_MODULE_INFO() declared somewhere in your program in order for your program to run.
We made a provision for autoconf scripts (such as the one used in SDL) so that they can link without PSP_MODULE_INFO(), but be warned that if you forget to declare it, your program will not run.
Note that this is no different than the old way of doing things, except previously the "module_info" was in startup.s.
See any of the PSPSDK samples if you want to see how it's used.
We made a provision for autoconf scripts (such as the one used in SDL) so that they can link without PSP_MODULE_INFO(), but be warned that if you forget to declare it, your program will not run.
Note that this is no different than the old way of doing things, except previously the "module_info" was in startup.s.
See any of the PSPSDK samples if you want to see how it's used.
Ok, I have looked at the sample's a bit, and have gotten to this point.
I modified my code, so now here it is:
and here is my make file:
and here is the output:
I modified my code, so now here it is:
Code: Select all
#include <pspkernel.h>
#include <pspdebug.h>
#include <stdlib.h>
#define printf pspDebugScreenPrintf
PSP_MODULE_INFO("SDKTEST", 0, 1, 1);
int main(void)
{
printf("Hello World");
return 0;
}
Code: Select all
all:
psp-gcc -g -O2 -G0 -Wall -c main.c
psp-gcc -g -O2 -G0 -Wall -lpspkernel -lpsplibc -lpspdebug -o main.o
Code: Select all
psp-gcc -g -O2 -G0 -Wall -c main.c
psp-gcc -g -O2 -G0 -Wall -lpspkernel -lpsplibc -lpspdebug -o main.o
psp/lib/crt0.o:/home/dev/pspsdk-1.0+beta/sdk/startup/crt0.S:110: undefined reference to `main'
psp/lib/crt0.o: In function `__entrytable':
crt0.S:(.rodata.sceResident+0xc): undefined reference to `module_info'
collect2: ld returned 1 exit status
Lego of my Ago!
Code: Select all
psp-gcc -g -O2 -G0 -Wall -lpspkernel -lpsplibc -lpspdebug -o main.o