libtool: Building modules
1
1 10.1 Building modules to dlopen
1 ===============================
1
1 On some operating systems, a program symbol must be specially declared
1 in order to be dynamically resolved with the 'dlsym' (or equivalent)
1 function. Libtool provides the '-export-dynamic' and '-module' link
1 flags (⇒Link mode), for you to make that declaration. You need
1 to use these flags if you are linking an application program that
1 dlopens other modules or a libtool library that will also be dlopened.
1
1 For example, if we wanted to build a shared library, 'hello', that
1 would later be dlopened by an application, we would add '-module' to the
1 other link flags:
1
1 burger$ libtool --mode=link gcc -module -o hello.la foo.lo \
1 hello.lo -rpath /usr/local/lib -lm
1 burger$
1
1 If symbols from your _executable_ are needed to satisfy unresolved
1 references in a library you want to dlopen you will have to use the flag
1 '-export-dynamic'. You should use '-export-dynamic' while linking the
1 executable that calls dlopen:
1
1 burger$ libtool --mode=link gcc -export-dynamic -o helldl main.o
1 burger$
1