[JDEV] Scripting/Modules/Rant

arh14 at cornell.edu arh14 at cornell.edu
Fri Aug 13 07:28:34 CDT 1999


look down

On Thu, 12 Aug 1999, Jon A. Cruz wrote:

> arh14 at cornell.edu wrote:
> 
> > On Wed, 11 Aug 1999, Aaron Brady (insomnike) wrote:
> >
> > > And example of how procedures are run from a .so file:
> > >
> > > void main(void) {
> > >  void *phoe = dlopen ("mod_filetrans.so", RTLD_LAZY);
> > >  int (*funk)(int) = dlsym(phoe, "handle_prefs");
> > >  printf ("[%d]\n", (*funk)(1));
> > >  dlclose(phoe);
> > > }
> >
> > Somewhat like the Win32 Way.  The same general thing happens: you load
> > the DLL (~dlopen), you find a pointer to the function you want (~dlsym),
> > then you use the pointer as a function pointer and call it (~*funk).
> 
> Well, actually that's the much lesser used Win32 way.
> 
> The more common way is just to statically link with a DLL's .LIB file, then
> the OS takes care of fixup at run-time. For the programmer it looks just
> like calling normal functions in a statically linked lib. Looks like this:

Yes, that is a bit easier (you just declare your imports).  For a 
plugin-type scenario it would be necessary to query the filesystem, see 
what the user has put in there (what plugins are in the plugin 
directory), and load em dynamically (or even on-demand in the life-cycle 
of the client).  I think Winamp does it this way.  Statically linking, 
although easier and probably more common, probably wouldn't work.  Java 
is nice in this way, since *everything* is dynamically loaded ;)

Love the Wierd Al sig ;)
Aaron

> 
> void main(void) {
>  printf ("[%d]\n", handle_prefs(1));
> }
> 
> 
> But then again, the point is that the dynamic load concept is not
> completely foreign to Win32 programmers.
> 
> --
> "My new computer's got the clocks, it rocks
> But it was obsolete before I opened the box" - W.A.Y.




More information about the JDev mailing list