dynamic libraries

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

Moderators: cheriff, TyRaNiD

Post Reply
daniel.franzini
Posts: 5
Joined: Tue Sep 01, 2009 8:24 pm
Location: São Paulo/SP (Brasil)

dynamic libraries

Post by daniel.franzini »

Hi all

I'm porting the BennuGD for the PSP. BennuGD is a programming language for writing 2D games.

In doing this, there is the need of some sort of dynamic loading (on Windows it is implemented using DLLs and in Linux, using Shared Libraries). Question: is a PRX module good for this? If a PRX is just in the same folder as the binaries, is the PSP able to load it?

I think i can "emulate" the behavior of i.e DLLs using loading/unloading functions of PRXs.

Does anyone has some other ideas on this?

Thank you!
jojojoris
Posts: 255
Joined: Sun Mar 30, 2008 4:06 am

Post by jojojoris »

You can use a prx as a DLL in windows. A prx can contain some functions. I think it's simpler to create just a librarie which you link against.

Code: Select all

int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
m0skit0
Posts: 191
Joined: Tue Jun 02, 2009 8:58 pm

Post by m0skit0 »

You have to define exported function. Check the SDK example about PRXs.
The Incredible Bill Gates wrote:The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

m0skit0 wrote:You have to define exported function. Check the SDK example about PRXs.
Also remember that while functions can be exported, the SDK doesn't allow you to access exported variables. If you wish to use variables from the main app, you have to pass them (or a pointer) in to the function, and if you wish to access a variable in the prx, you need to make accessor functions in the prx.

For example, if the prx has a variable called myVariable, to get or set it, you need to export functions like GetMyVariable() and SetMyVariable() - the main app cannot directly manipulate myVariable. In that respect, prx's are different from dlls and linux shared libraries.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

For exporting variables, use pointers for user->user or kernel->kernel exports. You'll have to use an accessor function for kernel->user variable exports.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Torch wrote:For exporting variables, use pointers for user->user or kernel->kernel exports. You'll have to use an accessor function for kernel->user variable exports.
Yeah, that's right. I was thinking of kernel prxs as that's what I've worked on. :)
daniel.franzini
Posts: 5
Joined: Tue Sep 01, 2009 8:24 pm
Location: São Paulo/SP (Brasil)

Post by daniel.franzini »

thank you for the answers. i will work on this.
phobox
Posts: 127
Joined: Mon Mar 24, 2008 6:22 pm

Post by phobox »

Torch wrote:For exporting variables, use pointers for user->user or kernel->kernel exports.
Can you please tell me how to import variables? what do you mean by saying "use pointers"?
do you mean to use a pointer and set to this pointer the address of the exported variable from the other module? but how to get this address?

thanks
Ciao! from Italy
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Call a function that returns a structure full of pointers to the variables you wish to access. Something like

struct myPointers {
int * var1;
int * var2;
char * var3;
};

When the prx function returns a pointer to the struct, you then have pointers to all the stuff in the PRX you want. You'd do something similar for passing pointers into the prx as well. This only works for a user prx <> user app or kernel prx <> kernel app.
m0skit0
Posts: 191
Joined: Tue Jun 02, 2009 8:58 pm

Post by m0skit0 »

Or you can just use an object-oriented-like method, like

Code: Select all

int my_global;

int return_my_global&#40;&#41;
&#123;
    return my_global;
&#125;
The Incredible Bill Gates wrote:The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

m0skit0 wrote:Or you can just use an object-oriented-like method, like

Code: Select all

int my_global;

int return_my_global&#40;&#41;
&#123;
    return my_global;
&#125;
I mentioned that earlier in the thread. ;)
m0skit0
Posts: 191
Joined: Tue Jun 02, 2009 8:58 pm

Post by m0skit0 »

True, my bad, sorry. But maybe with an code example he/she could understand the concept better.
The Incredible Bill Gates wrote:The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers.
Post Reply