Loading libraries run-time: dlopen, dlsym, dlclose

Loading libraries run-time: dlopen, dlsym, dlclose

Post by David Hugh Lew » Mon, 28 Apr 1997 04:00:00



I was reading through the man pages on my system and came across some
functions which seem to indicate that I can load a library at run-time
without statically linking the load information stubs into my program.
The functions in question are dlopen, dlsym, dlerror and dlclose.
They are especially of interest to me because my application has a
core which is static (ie in development) but which can be extended
without change by loading different libraries at different times.
For example, I may want my application to enter into a module by a
specific function name, and each of these functions has the same
argument type. This will be ideal if, for instance, I have three
different e-mail systems, and I want to be able to tie the three
together.

As I mentioned I found them in the man pages by man -k "dynamic link"
but there were no actual man pages. I found the prototypes in
/usr/include/dlfcn.h, but couldn't find which library to link into.

Does anyone know the library(s) or where I can get the right
information/documentation? It's not in the LPG - I checked.

Thanks in advance.

 
 
 

Loading libraries run-time: dlopen, dlsym, dlclose

Post by j.. » Mon, 28 Apr 1997 04:00:00




Quote:>I was reading through the man pages on my system and came across some
>functions which seem to indicate that I can load a library at run-time
>without statically linking the load information stubs into my program.
>The functions in question are dlopen, dlsym, dlerror and dlclose.
...
>As I mentioned I found them in the man pages by man -k "dynamic link"
>but there were no actual man pages.

The man pages are in the distribution kit.  
See GCC/ld.so-1.8.10.tar.gz or so in your favorite sunsite mirror.
ftp:/sunsite.unc.edu/pub/Linux/GCC/ld.so-1.8.10.tar.gz

These functions work wonderfully for modular systems.  Define
your calling interface and plug it together at run time as needed.
It more or less matches Sun's implementation of the same stuff.

                                        - jim studt

 
 
 

Loading libraries run-time: dlopen, dlsym, dlclose

Post by Tristan Tarra » Tue, 29 Apr 1997 04:00:00



Quote:> As I mentioned I found them in the man pages by man -k "dynamic link"
> but there were no actual man pages. I found the prototypes in
> /usr/include/dlfcn.h, but couldn't find which library to link into.

> Does anyone know the library(s) or where I can get the right
> information/documentation? It's not in the LPG - I checked.

Just link with -ldl

Tristan
--

Lo sai che la tua faccia somiglia a quella di uno che vale 2000 dollari ?
Gia'. Ma tu non somigli a quello che li incassa. Due passi indietro...
                              Il buono, il brutto e il cattivo

 
 
 

1. loader errors: dlclose, dlsym,dlopen

Hi,

I am getting the following errors:

Undefined                       first referenced
 symbol                             in file
dlclose                             /usr/lib/libc.a(nss_deffinder.o)
dlsym                               /usr/lib/libc.a(nss_deffinder.o)
dlopen                              /usr/lib/libc.a(nss_deffinder.o)

Any idea on how to get rid of it. I am using g++-2.95.2 on a Sparc
Solaris-7.

Thanks
Rajesh

2. SMC Power 100mbsp ethernet

3. dlopen/dlsym/dlclose?

4. Help! Redhat + Maxtor overlay

5. dlopen,dlclose,dlsym undefined problem

6. zombie processes

7. req: best/recommended ATA100 controller on 2.2.xx or 2.4.xx

8. compliation error (dlclose, dlsym, dlopen, etc)

9. Bugs in shared libraries (dlopen / dlclose)..

10. Shared libraries and dlopen/dlsym..

11. Need help with 'time' C Run-Time Library functions under HP-UX

12. Where are dlopen, dlclose, etc...