can C++ be used with PSPSDK

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

Moderators: cheriff, TyRaNiD

Post Reply
cooleyandy
Posts: 41
Joined: Sat Jul 02, 2005 10:12 am

can C++ be used with PSPSDK

Post by cooleyandy »

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.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

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 :).
cooleyandy
Posts: 41
Joined: Sat Jul 02, 2005 10:12 am

Post by cooleyandy »

I've tried the solution of changing pspmoduleinfo.h with extern and it works wonderfully. Thanks. I'm wondering why a "C++" search with the search would not turn up anything but I've found my solultion, so I'm happy.
User avatar
Agoln
Posts: 326
Joined: Wed Jun 08, 2005 3:14 am
Location: Fort Wayne, IN

Not using C++ and getting the error

Post by Agoln »

I am not using C++, I am just using ansi-c.

I am just trying to compile:

Code: Select all

#include <stdio.h>
int main&#40;&#41; &#123;
printf&#40;"Hello world"&#41;;
while&#40;1&#41;;
return 0;
&#125;
Here is my make file:

Code: Select all

all&#58;
	psp-gcc -g -c Main.c
	psp-gcc Main.o -o out -lpsplibc -lpspkernel -lpspdebug
	elf2pbp out
Here is the output:

Code: Select all

psp-gcc -g -c Main.c
psp-gcc Main.o -lpsplibc -lpspkernel -lpspdebug
../../../../psp/lib/crt0.o&#58; In function `__entrytable'&#58;
crt0.S&#58;&#40;.rodata.sceResident+0xc&#41;&#58; undefined reference to `module_info'
collect2&#58; ld returned 1 exit status

make&#58; *** &#91;all&#93; Error 1
Execution terminated
Please let me know if it's the same problem.
Lego of my Ago!
emigree
Posts: 5
Joined: Mon May 09, 2005 5:29 am

Post by emigree »

Yes, it's the same problem. It goes away it you get a new version of the sdk from svn. Or you could just add an extern to pspmoduleinfo.h as suggested.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

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.
User avatar
Agoln
Posts: 326
Joined: Wed Jun 08, 2005 3:14 am
Location: Fort Wayne, IN

Post by Agoln »

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:

Code: Select all

#include <pspkernel.h>
#include <pspdebug.h>
#include <stdlib.h>

#define printf	pspDebugScreenPrintf

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

int main&#40;void&#41;
&#123;
	printf&#40;"Hello World"&#41;;
	return 0;
&#125;
and here is my make file:

Code: Select all

all&#58;
	psp-gcc -g -O2 -G0 -Wall -c main.c
	psp-gcc -g -O2 -G0 -Wall -lpspkernel -lpsplibc -lpspdebug -o main.o 
and here is the output:

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&#58;/home/dev/pspsdk-1.0+beta/sdk/startup/crt0.S&#58;110&#58; undefined reference to `main'
psp/lib/crt0.o&#58; In function `__entrytable'&#58;
crt0.S&#58;&#40;.rodata.sceResident+0xc&#41;&#58; undefined reference to `module_info'
collect2&#58; ld returned 1 exit status
Lego of my Ago!
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Code: Select all

psp-gcc -g -O2 -G0 -Wall -lpspkernel -lpsplibc -lpspdebug -o main.o
The -o option specifies the name of the output file. You need to specify one :).
Post Reply