Linux Programmer’s Manual
dladdr, dlclose, dlerror, dlopen, dlsym, dlvsym − programming interface to dynamic linking loader
void *dlopen(const char * filename, int flag);
void *dlsym(void *handle, const char *symbol);
int dlclose(void *handle);
Link with −ldl.
The four functions dlopen(), dlsym(), dlclose(), dlerror() implement the interface to the dynamic linking
The function dlerror() returns a human readable string describing the most recent error that occurred from
dlopen(), dlsym() or dlclose() since the last call to dlerror(). It returns NULL if no errors have occurred
since initialization or since it was last called.
The function dlopen() loads the dynamic library file named by the null-terminated string filename and
returns an opaque "handle" for the dynamic library. If filename is NULL, then the returned handle is for
the main program. If filename contains a slash ("/"), then it is interpreted as a (relative or absolute) path-
name. Otherwise, the dynamic linker searches for the library as follows (see ld.so(8) for further details):
(ELF only) If the executable file for the calling program contains a DT_RPATH tag, and does not con-
tain a DT_RUNPATH tag, then the directories listed in the DT_RPATH tag are searched.
If, at the time that the program was started, the environment variable LD_LIBRARY_PATH was
defined to contain a colon-separated list of directories, then these are searched. (As a security measure
this variable is ignored for set-user-ID and set-group-ID programs.)
(ELF only) If the executable file for the calling program contains a DT_RUNPATH tag, then the direc-
tories listed in that tag are searched.
The cache file /etc/ld.so.cache (maintained by ldconfig(8)) is checked to see whether it contains an
entry for filename.
The directories /lib and /usr/lib are searched (in that order).
If the library has dependencies on other shared libraries, then these are also automati