Using C++ and Libraries with a prx
Using C++ and Libraries with a prx
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
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
uuuuuuuuuh what can you explain this again in idiots term because i dont understand this kinda new to c++ and pspsdk and psp programmingJ.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.
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.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
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
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.
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.