On Tue, 8 Jun 1999, Holger Waechtler wrote:

> Who says, that our super driver is not able to load it's subdrivers
> dynamically ??
> 
> (could you explain, how dlopen() is used ?? - works it on non-Unix
> platforms (MacOS, Dos, Windows) ?? -- if not, we could put some #ifdef's
> around it and link at unsupported platforms all subdrivers in the
> library.)
 
dlopen is really easy to understand:

     /*
       Grab the C math library - load it from disk NOW!
     */

     void *handle = dlopen ( "libm.so", RTLD_NOW ) ;

     /*
       Grab the address of the sqrt() function
     */

     my_sqrt = dlsym ( handle, "sqrt" ) ;

     /*
       Call the function
     */

     x = (*my_sqrt)( 4 ) ;

     /*
       Dump the library to save memory (optional)
       when you don't need it anymore.
     */

     dlclose ( handle ) ;

...tada!  (There is also a dlerror function)
 
There are similar functions available under Windoze - but
not with the same API - so some #ifdef WIN32's are going to
be needed.

I understand that there are still some Unixen that don't
have dlopen/dlsym/dlclose - I don't know what the deal
is with MacOS, Amiga and some of the other more obscure
platforms.  I bet BeOS has dlopen - but I don't know
for sure.

Steve Baker                (817)619-2657 (Vox/Vox-Mail)
Raytheon Systems Inc.      (817)619-2466 (Fax)
Work: [EMAIL PROTECTED]      http://www.hti.com
Home: [EMAIL PROTECTED] http://web2.airmail.net/sjbaker1



_______________________________________________
Mesa-dev maillist  -  [EMAIL PROTECTED]
http://lists.mesa3d.org/mailman/listinfo/mesa-dev

Reply via email to