dlclose() — Close a dlopen() object
|Standards / Extensions||C or C++||Dependencies|
Single UNIX Specification, Version 3
#define _UNIX03_SOURCE #include <dlfcn.h> int dlclose(void *handle);
Informs the system that the dynamic link library (DLL) referenced by a handle returned from a previous dlopen() invocation is no longer needed by the application. Once a DLL has been closed, an application should assume that its symbols and the symbols of any dependent DLLs are no longer available to dlsym().
NULL is returned if the referenced DLL was successfully closed. If the DLL could not be closed, or if handle does not refer to an open DLL, a non-zero value will be returned.
- A conforming application should use a handle returned from a dlopen() invocation only within a given scope, bracketed by the dlopen() and dlclose() operations. The value of a handle must be treated as an opaque object by the application, used only in calls to dlsym() and dlclose().
- DLLs that are loaded explicitly, that is with dlopen(), and are not freed with a corresponding call to dlclose(), are freed automatically at enclave termination in LIFO sequence.
- Non-local C++ static destructors defined in a DLL are executed only once, when the DLL program object is deleted from memory.
- More detailed diagnostic information is available through dlerror(), the _EDC_DLL_DIAG environment variable, and the Language Environment® DLL Failure control block (CEEDLLF) chain.
- This function is not available under SPC, MTF and CSP environments.
... /* Open a dynamic library and then close it ... */ #include <dlfcn.h> void *mylib; int eret; mylib = dlopen("mylib.so", RTLD_LOCAL | RTLD_LAZY); ... eret = dlclose(mylib); ...