3.2.1 Shared Libraries

You must link the ".o" file to produce a shared library. This is done using a special invocation of the Unix loader/linker, ld(1). Unfortunately the invocation differs slightly per system.

On SunOS 4, use

ld spammodule.o -o spammodule.so

On Solaris 2, use

ld -G spammodule.o -o spammodule.so

On SGI IRIX 5, use

ld -shared spammodule.o -o spammodule.so

On other systems, consult the manual page for ld(1) to find what flags, if any, must be used.

If your extension module uses system libraries that haven't already been linked with Python (e.g. a windowing system), these must be passed to the ld command as "-l" options after the ".o" file.

The resulting file "spammodule.so" must be copied into a directory along the Python module search path.


guido@python.org