libexec (Re: "kde5" or "kf5" ?)
Alexander Neundorf
neundorf at kde.org
Fri Feb 22 19:21:57 UTC 2013
On Friday 22 February 2013, David Faure wrote:
> On Thursday 21 February 2013 19:20:56 Alexander Neundorf wrote:
...
> > Is there a way to find out where a library itself is located ?
>
> Not that I know.
Found something :-)
Under Windows it's GetModuleHandleEx(), with glibc dladdr() (see attached
example) works.
The man page says it's not portable, but at least there are also man pages for
dladdr() for FreeBSD, OSX and SunOS.
IMO this should be good enough.
This is how it is done for cmake's Config.cmake files:
if a path is not in the same prefix as the Config.cmake file, the full
absolute path is configured into the Config.cmake file.
If the other path (e.g. to libexec) is in the same prefix, the relative path
is configured into the Config.cmake file.
We could do the same with libraries.
If LIBEXEC_INSTALL_DIR is in the same prefix as LIB_INSTALL_DIR (it usually
is), we configure the relative path into the library. If it is somewhere else,
(or if LIB_INSTALL_DIR is /lib[64] or /usr/lib[64]), we can configure the full
path to the other directory into the library.
At runtime we then check whether we have a relative or absolute path to the
directory in question, and if it is relative, we find ourselves and append the
relative path to our location.
Then we should have it.
Alex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dladdr.tar.gz
Type: application/x-compressed-tar
Size: 620 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20130222/2b6b3c07/attachment.tar.gz>
More information about the Kde-frameworks-devel
mailing list