+ <literal>-shared</literal>.
+ </para>
+ </sect2>
+
+ <sect2>
+ <title>Shared libraries that export a C API</title>
+ <para>
+ Building Haskell code into a shared library is a good way to include
+ Haskell code in a larger mixed-language project. While with static
+ linking it is recommended to use GHC to perform the final link step,
+ with shared libaries a Haskell library can be treated just like any
+ other shared libary. The linking can be done using the normal system C
+ compiler or linker.
+ </para>
+ <para>
+ It is possible to load shared libraries generated by GHC in other
+ programs not written in Haskell, so they are suitable for using as
+ plugins. Of course to construct a plugin you will have to use the FFI
+ to export C functions and follow the rules about initialising the RTS.
+ See <xref linkend="ffi-library"/>. In particular you will probably want
+ to export a C function from your shared library to initialise the
+ plugin before any Haskell functions are called.
+ </para>
+ <para>
+ To build Haskell modules that export a C API into a shared library use
+ the <literal>-dynamic</literal>, <literal>-fPIC</literal> and