[Distutils] SWIG runtime libs/Python distutils combo on Mac

Bob Ippolito bob at redivi.com
Mon Sep 27 18:19:28 CEST 2004

On Sep 27, 2004, at 12:03 PM, Bill Spotz wrote:

> To get around the portability problem, I have decided to use python's 
> distutils module to handle the compilation issues.  In my setup.py 
> script, I define
>   SwigRun = Extension("PyTrilinos.libswigrun", ["src/swigrun_wrap.c"])
> and this works, as build/lib.blahblahblah/PyTrilinos/libswigrun.so 
> gets created properly.  When I define real extensions in setup.py, 
> they are created with keyword arguments
>     library_dirs    = [..., "build/lib.blahblahblah/PyTrilinos", ...],
>     libraries       = [..., "swigrun", ...],
> which gives me the link command arguments I want: 
> -Lbuild/lib.blahblahblah/PyTrilinons -lswigrun.  However, on my Mac, 
> when the link command is invoked, I get
>     ld: can't locate file for: -lswigrun
> I strongly suspect that the Mac's ld command does not search for 
> libswigrun.so when -lswigrun is given as a command line argument (the 
> old system libraries have .la and .dylib extensions).  But I cannot 
> figure out how to get setup.py to compile to a different suffix.

You can't do this on OS X.  You can link to two types of files in OS X, 
static libraries and dylibs.  Python extension modules are bundles 
(runtime loadable code) and can not be linked to at compile time.  You 
should either compile swigrun_wrap into every extension, or make it a 
static library (which is more or less the same thing).


More information about the Distutils-SIG mailing list