[Pythonmac-SIG] Static Linking...
Chris Barker - NOAA Federal
chris.barker at noaa.gov
Fri May 24 01:41:35 CEST 2013
As a side note to the main thread about dependencies:
How can I static link?
I"ve struggled for literally years to get gcc to statically link, but
it tries really hard to dynamically link instead. I have written way
too many scripts that move or re-name dynamic libs temporarily while
building, then put them back after.
Then a colleague of mine showed me the really neat trick -- pass the
paths to the libs themselves through to gcc with "extra_objects"
keyword in the Extension object, like so:
extra_objects = ["libhdf5.a", "libhdf5_hl.a", "libnetcdf.a"]
extensions = [Extension("netCDF4",
sources,
libraries=libs,
include_dirs=inc_dirs,
extra_objects=extra_objects,
)]
very nifty -- works like a charm.
However, when I do this, I had to re-write part of the setup.py --
actually, making it far more simple -- in this case, there was a lot
of machinations finding the libs...
But Ideally, I"d ;like to build a semi-arbitrary extension with static
linking while using the existing setup.py. Is there a way to
minkey-path the setup, so I can use the existing one, but re-shuffle
it some in place before the actual build occurs?
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the Pythonmac-SIG
mailing list