manpagez: man pages & more
info libtool
Home | html | info | man

File: libtool.info,  Node: Building modules,  Next: Dlpreopening,  Up: Dlopened modules

10.1 Building modules to dlopen
===============================

On some operating systems, a program symbol must be specially declared
in order to be dynamically resolved with the ‘dlsym’ (or equivalent)
function.  Libtool provides the ‘-export-dynamic’ and ‘-module’ link
flags (*note Link mode::), for you to make that declaration.  You need
to use these flags if you are linking an application program that
dlopens other modules or a libtool library that will also be dlopened.

   For example, if we wanted to build a shared library, ‘hello’, that
would later be dlopened by an application, we would add ‘-module’ to the
other link flags:

     burger$ libtool --mode=link gcc -module -o hello.la foo.lo \
                     hello.lo -rpath /usr/local/lib -lm
     burger$

   If symbols from your _executable_ are needed to satisfy unresolved
references in a library you want to dlopen you will have to use the flag
‘-export-dynamic’.  You should use ‘-export-dynamic’ while linking the
executable that calls dlopen:

     burger$ libtool --mode=link gcc -export-dynamic -o helldl main.o
     burger$

© manpagez.com 2000-2025
Individual documents may contain additional copyright information.