[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, 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.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The dlerror subroutine, dlopen subroutine, dlsym subroutine, load subroutine, loadquery subroutine, unload subroutine, loadbind subroutine.

The ld command.

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

[ Previous | Next | Contents | Glossary | Home | Search ]