dlopen

Name

dlopen -- open dynamic object

Synopsis

#include <dlfcn.h>

void * dlopen(const char * filename, int flag);

Description

The dlopen() function shall behave as specified in POSIX 1003.1-2008 (ISO/IEC 9945-2009), but with additional behaviors listed below.

If the file argument does not contain a <slash> character, then the system shall look for a library of that name in at least the following directories, and use the first one which is found:

Additional flags

In addition to the available values for flag as documented in POSIX 1003.1-2008 (ISO/IEC 9945-2009), the following values may also be ORed into flag:

RTLD_NODELETE 

Do not unload the library during dlclose(). Consequently, the library's static variables are not reinitialized if the library is reloaded with dlopen() at a later time.

RTLD_NOLOAD 

Do not load the library. This can be used to test if the library is already resident. dlopen() returns a NULL pointer if it is not resident; it returns the library's handle if it is resident. This flag can also be used to promote the flags on a library that is already loaded. For example, a library that was previously loaded with RTLD_LOCAL can be reopened using RTLD_NOLOAD|RTLD_GLOBAL.

RTLD_DEEPBIND 

Place the lookup scope of the symbols in this library ahead of the global scope. This means that a self-contained library will use its own symbols in preference to global symbols with the same name contained in libraries that have already been loaded.