[Distutils] static linking in distutils/setuptools?

Robert Kern robert.kern at gmail.com
Thu Jan 26 23:12:29 CET 2006

Matthias Urlichs wrote:
> Hi,
> Robert Kern:
>>Not really, no. In many cases (e.g., GNU ld), there's simply no way to
>>tell the linker that you prefer static libraries to shared libraries
>>when you are building a shared library like a Python extension. You
>>simply have to make sure that the static libraries are found first.
> Note: Linking static code (gcc without -fpic => foo.o => libfoo.a) into
> a shared library (lib*.so) is a bad idea. On i386, the required
> relocation means that the static library's text is not shared between
> concurrent invocations, and loading the library is more expensive too.
> On some other architectures, either linking the library, or loading it,
> will simply fail.
> You need to build an archive of shared objects (same as above, but use
> -fpic or equivalent). These are usually named lib*_pic.a IIRC.

On OS X (the platform Chris is building for), -fPIC is the default for
everything, so the operation is fairly safe, if not optimal.

Robert Kern
robert.kern at gmail.com

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

More information about the Distutils-SIG mailing list