Joerg Schilling wrote: > Is there a way to reliably retrieve the path to a library? > > I tried to opendir("/proc/<pid>/path/") > and readdir()/readlink() the entries. If all library > names differ, this allows to find the path to any lib of > interest. > > Unfortunately, this does not help if there are two > libraries with the same name (e.g. /tmp/libm.so.2 > and /lib/libm.so.2). Is there a way to get the > path that is related to a handle returned by dlopen()?
If I remember correctly the function you want is dladdr(3C) and the member of the structure is dli_fname. If I am not remembering correctly someone on tools-linking (cc'd) will be able to help you. -- Darren J Moffat