<a name="Tcl_nn4">37.1.2 Compiling a dynamic module</a></H3>


<p>
The preferred approach to building an extension module is to compile it into
a shared object file or DLL. Assuming you have code you need to link to in a file
called <tt>example.c</tt>, you will need to compile your program
using commands like this (shown for Linux):
</p>

<div class="code"><pre>
$ swig -tcl example.i
$ gcc -fPIC -c example.c
$ gcc -fPIC -c example_wrap.c -I/usr/local/include
$ gcc -shared example.o example_wrap.o -o example