[Pythonmac-SIG] GDAL python bindings?

Darran Edmundson darran.edmundson at anu.edu.au
Thu Jan 27 15:17:14 CET 2005


Bob Ippolito wrote:

> GDAL is broken-ish because it doesn't use distutils to link modules.
> 
> Try this:
> 
> env MACOSX_DEPLOYMENT_TARGET=10.3 g++ -Wl,-bind_at_load  -o 
> .libs/_gdalmodule.so -bundle .libs/gdal_wrap.o .libs/numpydataset.o 
> .libs/gdalnumeric.o ../.libs/libgdal.dylib -bundle -undefined 
> dynamic_lookup

Thanks so much Bob.  I can't say I understand it but it was enough to
get the job done.  A few tweaks, listed here for the benefit of others
running into this problem in future:

1) To recap, a 'configure; make' of gdal-1.2.5 from source almost works,
compiling all the gdal core but failing a link step with lots of undefined
Python symbols.

2) In the same dir,

$ env MACOSX_DEPLOYMENT_TARGET=10.3 g++ -Wl,-bind_at_load  -o 
.libs/_gdalmodule.so -bundle ./pymod/.libs/gdal_wrap.o 
./pymod/.libs/numpydataset.o ./pymod/.libs/gdalnumeric.o 
.libs/libgdal.dylib -bundle -undefined dynamic_lookup


3) 'make' will still fail, so I hand-copied the following as root

gdal-1.2.5 root# cp .libs/libgdal.1.6.0.dylib /usr/local/lib/
gdal-1.2.5 root# cp .libs/libgdal.1.dylib /usr/local/lib/
gdal-1.2.5 root# cp .libs/libgdal.a /usr/local/lib/
gdal-1.2.5 root# cp .libs/libgdal.dylib /usr/local/lib/
gdal-1.2.5 root# cp .libs/libgdal.la /usr/local/lib/


4) "python setup.py install"

5) Start python and "import gdal"

gdal-1.2.5 root# python
Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import gdal
 >>> dir(gdal)
['AllRegister', 'AutoCreateWarpedVRT', 'Band', 'CE_Debug', 'CE_Failure', 
'CE_Fatal', 'CE_None', 'CE_Warning', 'CPLES_BackslashQuotable', 
'CPLES_CSV', 'CPLES_SQL', 'CPLES_URL', 'CPLES_XML', 'CPLE_AppDefined', 
'CPLE_AssertionFailed', 'CP ...

Works for me, though I haven't yet tried to use the code.  Bob might 
want to comment
on the (lack of?) wisdom of step 3.

Thanks again,
Darran.

-- 
Darran Edmundson (darran.edmundson at anu.edu.au)
ANU Supercomputer Facility Vizlab
Australian National University, Canberra, ACT 2600
tel: +61 2 6125-0517  fax: +61 2 6125-5088


More information about the Pythonmac-SIG mailing list