[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1

dlclose Subroutine


Closes and unloads a module loaded by the dlopen subroutine.


#include <dlfcn.h>

int dlclose(Data);
void *Data;


The dlclose subroutine is used to remove access to a module loaded with the dlopen subroutine. In addition, access to dependent modules of the module being unloaded is removed as well.

Modules being unloaded with the dlclose subroutine will not be removed from the process's address space if they are still required by other modules. Nevertheless, subsequent uses of Data are invalid, and further uses of symbols that were exported by the module being unloaded result in undefined behavior.


Data A loaded module reference returned from a previous call to dlopen.

Return Values

Upon successful completion, 0 (zero) is returned. Otherwise, errno is set to EINVAL, and the return value is also EINVAL. Even if the dlclose subroutine succeeds, the specified module may still be part of the process's address space if the module is still needed by other modules.

Error Codes

EINVAL The Data parameter does not refer to a module opened by dlopen that is still open. The parameter may be corrupt or the module may have been unloaded by a previous call to dlclose.

Related Information

The dlerror (dlerror Subroutine) subroutine, dlopen (dlopen Subroutine) subroutine, dlsym (dladdr Subroutine) subroutine, load (load Subroutine) subroutine, loadquery (loadquery Subroutine) subroutine, unload subroutine, loadbind (loadbind Subroutine) subroutine.

The ld command.

The Shared Libraries and Shared Memory Overview and Subroutines Overview in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]