Joe Lewis wrote:
I've read that I can't export symbols from the parent executable to
modules opened with dlopen(). So, I have a (hopefully) quick question.
How can I export function(s) to those modules?
Joe Lewis
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Read the autobook at http://sources.redhat.com/autobook/ .
From section 18.1:
[...]
For instance, your main application may provide some utility function,
`my_function', which you want a module to have access to. There are two
ways to do that:
* You could use Libtool to link your application, using the
`-export-dynamic' option to ensure that the global application symbols
are available to modules. When libltdl loads a module into an
application compiled like this, it will back-link symbols from the
application to resolve any otherwise undefined symbols in a module. When
the module is `ltdlopen'ed, libltdl will arrange for calls to
`my_function' in the module, to execute the `my_function' implementation
in the application.
If you have need of this functionality, relying on back-linking
is the simplest way to achieve it. Unfortunately, this simplicity is at
the expense of portability: some platforms have no support for
back-linking at all, and others will not allow a module to be created
with unresolved symbols. Never-the-less, libltdl allows you to do this
if you want to.
* You could split the code that implements the symbols you need to
share with modules into a separate library. This library would then be
used to resolve the symbols you wish to share, by linking it into
modules and application alike. The definition of `my_function' would be
compiled separately into a library, `libmy_function.la'. References to
`my_function' from the application would be resolved by linking it with
`libmy_function.la', and the library would be installed so that modules
which need to call `my_function' would be able to resolve the symbol by
linking with `-lmy_function'.
This method requires support for neither back-linking nor
unresolved link time symbols from the host platform. The disadvantage is
that when you realise you need this functionality, it may be quite
complicated to extract the shared functionality from the application to
be compiled in a stand alone library.
[...]
Francesco Casadei
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"