forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

can C++ be used with PSPSDK

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
cooleyandy



Joined: 02 Jul 2005
Posts: 41

PostPosted: Sun Jul 03, 2005 5:25 pm    Post subject: can C++ be used with PSPSDK Reply with quote

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.
Back to top
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Sun Jul 03, 2005 6:42 pm    Post subject: Reply with quote

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 :).
Back to top
View user's profile Send private message
cooleyandy



Joined: 02 Jul 2005
Posts: 41

PostPosted: Mon Jul 04, 2005 6:28 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Agoln



Joined: 08 Jun 2005
Posts: 326
Location: Fort Wayne, IN

PostPosted: Wed Jul 06, 2005 12:36 pm    Post subject: Not using C++ and getting the error Reply with quote

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

I am just trying to compile:
Code:
#include <stdio.h>
int main() {
printf("Hello world");
while(1);
return 0;
}


Here is my make file:
Code:

all:
   psp-gcc -g -c Main.c
   psp-gcc Main.o -o out -lpsplibc -lpspkernel -lpspdebug
   elf2pbp out


Here is the output:
Code:

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


Please let me know if it's the same problem.
_________________
Lego of my Ago!
Back to top
View user's profile Send private message AIM Address
emigree



Joined: 09 May 2005
Posts: 5

PostPosted: Wed Jul 06, 2005 3:38 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Wed Jul 06, 2005 6:09 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Agoln



Joined: 08 Jun 2005
Posts: 326
Location: Fort Wayne, IN

PostPosted: Thu Jul 07, 2005 12:47 pm    Post subject: Reply with quote

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:
#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;
}


and here is my make file:

Code:

all:
   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:

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!
Back to top
View user's profile Send private message AIM Address
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Thu Jul 07, 2005 1:02 pm    Post subject: Reply with quote

Code:

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 :).
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group