rld Manual
Using the rld Loader Library
RLD Manual—528857-006
2-8
dlclose()
dlclose()
Summary
The dlclose() function invalidates the library handle designated by the
dlopen_handle value. It unloads any DLLs that are no longer required.
Syntax for C/C++ Programmers
Parameters
dlopen_handle
specifies a currently valid library handle previously returned by a call to the
dlopen() function.
Return Values
Upon successful invalidation of the library handle, dlclose() returns 0 (zero).
Otherwise, the function returns a nonzero value, and you should call the dlerror()
or dlresultcode() function immediately to determine the problem.
Considerations
The dlclose() function invalidates the library handle designated by the
dlopen_handle value. It unloads any DLLs that are no longer required.
In the simplest case, dlclose() unloads any library loaded by the dlopen()
invocation that returned the destroyed library handle. When there are linkages between
DLLs loaded by separate dlopen() calls, a library loaded by one call might be
required by a library loaded by another call and might be unloaded by a subsequent
call to dlclose() specifying another library handle.
dlclose() does not unload the main program or DLLs that were loaded with the
main program.
When dlclose() invalidates a library handle, it decrements the usage count for the
library loaded by the dlopen() invocation that returned the destroyed handle and for
any DLLs that library required. dlclose() unloads any DLLs that are unused.
After a library has been unloaded by dlclose(), referencing addresses where the
library text and data were loaded results in undefined behavior.
The dlclose() function does not set the errno variable. For error information, call
the dlerror() or dlresultcode() function.
#include <dlfcn.h>
int dlclose (dlHandle dlopen_handle );