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 

Using C++ and Libraries with a prx

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



Joined: 20 Oct 2008
Posts: 355

PostPosted: Mon Nov 03, 2008 10:55 am    Post subject: Using C++ and Libraries with a prx Reply with quote

i posted something similar to this before but this is different

How can i compile a user mode prx that uses c++ classes and linking because when i use extern "C" {} it wont compile because the objects like a object defined but not initialized in the cpp file as a local variable only visible in the cpp file are not recognized or even seen for that matter inside of the cpp file oh and it wont compile period without extern "C" even if it is c code and i change the file to a cpp file
Back to top
View user's profile Send private message MSN Messenger
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Mon Nov 03, 2008 11:56 am    Post subject: Reply with quote

You'll need to call the initializers from the module start routine. Look at how the normal start code calls the initializers, then put something similar in the start. Then when the prx is loaded, it should call the init routines.
Back to top
View user's profile Send private message AIM Address
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Mon Nov 03, 2008 12:11 pm    Post subject: Reply with quote

J.F. wrote:
You'll need to call the initializers from the module start routine. Look at how the normal start code calls the initializers, then put something similar in the start. Then when the prx is loaded, it should call the init routines.


uuuuuuuuuh what can you explain this again in idiots term because i dont understand this kinda new to c++ and pspsdk and psp programming
Back to top
View user's profile Send private message MSN Messenger
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Mon Nov 03, 2008 3:21 pm    Post subject: Reply with quote

No, I can't. This isn't a task for idiots (pardon my French). You'll need to know more about low-level C++ support before you can do this, or get someone else to take care of that for you. Personally, I can't stand C++, so don't look to me for this. Sorry.
Back to top
View user's profile Send private message AIM Address
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Mon Nov 03, 2008 11:27 pm    Post subject: Reply with quote

anyone else care to take a gander at this
Back to top
View user's profile Send private message MSN Messenger
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Tue Nov 04, 2008 6:56 am    Post subject: Reply with quote

basically i dont like having to use extern "C" and the c linking with EBOOT.PBP you can use c++ just fine with no extern "C" but why is it so different when doing a prx and could someone just explain what that guy said
Back to top
View user's profile Send private message MSN Messenger
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue Nov 04, 2008 8:02 am    Post subject: Reply with quote

Read this thread for an idea of what's going on...

http://forums.ps2dev.org/viewtopic.php?t=778
Back to top
View user's profile Send private message AIM Address
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Tue Nov 04, 2008 8:14 am    Post subject: Reply with quote

ok i read it, alot of stuff i didnt understand, so what i still dont get it how come it works on an eboot but not a prx , i'm a beginner when it comes to this topic, doesnt the eboot and prx use the same gcc compiler
Back to top
View user's profile Send private message MSN Messenger
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue Nov 04, 2008 8:34 am    Post subject: Reply with quote

coolkehon wrote:
ok i read it, alot of stuff i didnt understand, so what i still dont get it how come it works on an eboot but not a prx , i'm a beginner when it comes to this topic, doesnt the eboot and prx use the same gcc compiler


The EBOOT elf has crt0.S included into it, which calls the functions talked about. The prx specifically DOESN'T have crt0.S included... it's in the makefile not to! You'll have to take the code needed from crt0.S and insert it into the module start code to do the same thing. I'm not sure that will work since I don't believe anyone has tried making C++ prx's. You'll be in uncharted territory and have to work much of it out yourself.
Back to top
View user's profile Send private message AIM Address
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Tue Nov 04, 2008 9:07 am    Post subject: Reply with quote

thanks for your help on this and i see what your saying now but seems like i remeber something about the eboot calling module_start also i know thats off topic , now about that crt0.S can i just put the crt0.S in my makefile and it work or is there something else needed, one more thing what about prx's that have their own int main(int args,void *args[]) do they have crt0.S included, and one more thing when a int main() prx's main thread ends does the module end and unload itself to where the exports can be called or what thanks for your help
Back to top
View user's profile Send private message MSN Messenger
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue Nov 04, 2008 10:10 am    Post subject: Reply with quote

In the thread where I posted the example user prx, I posted that not making a main thread in the prx makes the app call the module_start on it's own thread. That's probably what you're thinking of.

You might want to read the PDF on PSP modules that was linked in one of your threads. It's got all the info you need, but it's pretty deep. It's not really meant for beginners. That will have the info on prx's that have a main thread with a main() entry. I don't think you need that in your case. Also, the question about the module stopping/unloading will be in the PDF as well. It's a good read, but it'll be tough since you're just starting at this.

You can't use the regular crt0.s in your prx as it's not meant for such a thing. It's meant for starting a full app, not a loadable library. You pretty much want to copy the portion that inits the C++ junk and forget the rest.
Back to top
View user's profile Send private message AIM Address
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Tue Nov 04, 2008 11:02 am    Post subject: Reply with quote

so how do i know what is the c++ junk and what is not
Back to top
View user's profile Send private message MSN Messenger
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue Nov 04, 2008 11:58 am    Post subject: Reply with quote

Try googling on the info in that thread I linked above. You'll have to track it down through web articles or find someone with that level of C++ knowledge.
Back to top
View user's profile Send private message AIM Address
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