IMPORTANT: You must compile your extension module with the additional C flag "-G0" (or "-G 0"). This instructs the assembler to generate position-independent code.
You don't need to link the resulting "spammodule.o" file; just copy it into a directory along the Python module search path.
The first time your extension is loaded, it takes some extra time and a few messages may be printed. This creates a file "spammodule.ld" which is an image that can be loaded quickly into the Python interpreter process. When a new Python interpreter is installed, the dl package detects this and rebuilds "spammodule.ld". The file "spammodule.ld" is placed in the directory where "spammodule.o" was found, unless this directory is unwritable; in that case it is placed in a temporary directory.3.1
If your extension modules uses additional system libraries, you must create a file "spammodule.libs" in the same directory as the "spammodule.o". This file should contain one or more lines with whitespace-separated options that will be passed to the linker -- normally only "-l" options or absolute pathnames of libraries (".a" files) should be used.