[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lt_dlopenadvise ignores advice
From: |
Gary V. Vaughan |
Subject: |
Re: lt_dlopenadvise ignores advice |
Date: |
Sun, 20 Apr 2008 16:34:15 -0400 |
Hi Anton,
Thanks for the report.
On 18 Apr 2008, at 11:47, Anton Ertl wrote:
Here's the my_dlopenext example:
#include <ltdl.h>
#include <stdio.h>
lt_dlhandle
my_dlopenext (const char *filename)
{
lt_dlhandle handle = 0;
lt_dladvise advise;
if (lt_dladvise_init (&advise)) {
fprintf(stderr,"lt_dladvise_init: %s\n",lt_dlerror());
exit(1);
}
if (lt_dladvise_ext (&advise)) {
fprintf(stderr,"lt_dladvise_ext: %s\n",lt_dlerror());
exit(1);
}
handle = lt_dlopenadvise (filename, &advise);
The documentation is wrong here (patch forthcoming), and your
program will work better if you use:
handle = lt_dlopenadvise (filename, advise);
lt_dladvise_destroy (&advise);
return handle;
}
You should be aware however, that opening libraries (as opposed
to modules) is not entirely portable. For example Mac OS X has
foo.dylib for shared libraries that will be opened by the linker
at run time, and foo.so for modules that are openable with dlopen()
and equivalent.
On architectures with a runtime loader that can't handle dependent
libraries (for example a math.so module that was linked with -lm),
lt_dlopen() et. al. will portably open those dependency libraries
(eg libm.so) provided you installed and open the appropriate .la
file.
In other words, lt_dlopen("math.la") will automatically load libm.so
on those hosts that require it without forcing you to write non-
portable code.
Cheers,
Gary
--
())_. Email me: address@hidden
( '/ Read my blog: http://blog.azazil.net
/ )= ...and my book: http://sources.redhat.com/autobook
`(_~)_
PGP.sig
Description: This is a digitally signed message part