This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
dlclose() on a library with dependencies
- From: Andrew Murchison <amurchis at ca dot ibm dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Wed, 16 Mar 2005 14:11:59 -0500
- Subject: dlclose() on a library with dependencies
I need to have an understanding about how dlopen() and dlclose() work when
a libary is both loaded into the program explicitly with dlopen() and
implicitly through a dlopen() of a second library which is linked with the
first.
What I am seeing is that I am occasionally getting the error (through
dlerror()) "Cannot close '<library name>' due to remaining dependencies"
when I unload libraries. I'm guessing what is happening here is that I
explicitly loaded through dlopen() both libraryA and libraryB loaded, with
libraryB having a dependency (linked with) libraryA which caused an
implicit load, and that I'm trying to explicitly unload (dlclose())
libraryA before libraryB.
However, is that REALLY what should happen? I'm not entirely sure what
order the libraries were loaded in either -- it might have been libraryB
before libraryA, for example. Will that have an effect? Also, if the
dlclose() fails with the above error for libraryA, and I later unload
libraryB, do I need to issue another call to dlclose() on libraryA again to
get it to unload or will a subsequent dlclose() fail? It is important to
note that, in this case, I can control neither the order in which the
libraries are loaded (dlopen) or unloaded (dlclose), and my program is
unaware of of any dependencies that might exist between libraries that are
loaded.
FYI, I'm specifically seeing this error on HPUX, so I don't think this is
actually using the glibc libraries. However, I hope someone can provide me
with an idea of what is SUPPOSED to happen
Thank you!
Andrew Murchison
NOTICE:
The questions I ask are strictly my own and dhon't necessarily have
anything to do with IBM.