Kyng Chaos
“The beast is actively interested only in now, and, as it is always now and always shall be, there is an eternity of time for the accomplishment of objects.”
- the wisdom of Tarzan

GDAL/OGR Build

:!: in progress

version: 1.6.2
source: http://www.gdal.org/

The GDAL build is mostly straightforward. GRASS support is a tricky bit, but easily solved - use a separate plugin.

Patches

First up, a patch.

iODBC

To use the system iODBC instead needing to build a separate UnixODBC.

Edit configure.

Change all occurrences of "-lodbc" with "-liodbc" (case sensitive, not whole words).

Edit port/cpl_odbc.h. Change the odbcinst include to:

#include <iodbcinst.h>

Leopard

64bit note: the ARCHFLAGS option below will build the Python modules 64bit. The Python libraries needed are 64bit on Leopard, but the executable is not. It's here mainly for completeness and ready for the day when Python is fully 64bit on OSX.

configure

In the GDAL source:

export MACOSX_DEPLOYMENT_TARGET=10.5
export ARCHFLAGS="-arch ppc -arch i386 -arch ppc64 -arch x86_64"
./configure --with-threads --disable-static --without-grass --with-jasper=/usr/local \
--with-libtiff=/usr/local --with-jpeg=/usr/local --with-gif=/usr/local --with-png=/usr/local \
--with-geotiff=internal --with-sqlite3=/usr --with-odbc --with-pcraster=internal \
--with-geos=/usr/local/bin/geos-config --with-static-proj4=/usr/local --with-expat=/usr/local \
--with-xerces --with-xerces-inc=/usr/local/include \
--with-xerces-lib="-L/usr/local/lib -lxerces-c -framework CoreServices" --with-curl --with-python \
--with-macosx-framework CFLAGS="-Os -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CXXFLAGS="-Os -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
LDFLAGS="-arch i386 -arch x86_64 -arch ppc -arch ppc64"

If you installed any of these optional packages, add to the configure line:

PostgreSQL –with-pg=/usr/local/pgsql/bin/pg_config
MrSID Geo DSDK –with-mrsid=
and drag the MrSID Geo DSDK folder from the Finder to the Terminal window.
MySQL –with-mysql=/usr/local/mysql/bin/mysql_config
NetCDF –with-netcdf=/usr/local
HDF 4 & 5 –with-hdf4=/usr/local –with-hdf5=/usr/local
OGDI –with-ogdi=/usr/local
CFITSIO –with-cfitsio=/usr/local
DAP –with-dods-root=/usr/local
ECW –with-ecw=/usr/local

port/cpl_config.h

Replace lines:

HOST_FILLORDER line with:

#ifdef __BIG_ENDIAN__
  #define HOST_FILLORDER FILLORDER_MSB2LSB
#else
  #define HOST_FILLORDER FILLORDER_LSB2MSB
#endif

SIZEOF_LONG line with:

#ifdef __LP64__
  #define SIZEOF_LONG 8
#else
  #define SIZEOF_LONG 4
#endif

SIZEOF_UNSIGNED_LONG line with:

#ifdef __LP64__
  #define SIZEOF_UNSIGNED_LONG 8
#else
  #define SIZEOF_UNSIGNED_LONG 4
#endif

SIZEOF_VOIDP line with:

#ifdef __LP64__
  #define SIZEOF_VOIDP 8
#else
  #define SIZEOF_VOIDP 4
#endif

WORDS_BIGENDIAN line with:

#ifdef __BIG_ENDIAN__
  #define WORDS_BIGENDIAN 1
#else
  #undef WORDS_BIGENDIAN
#endif

VSI_STAT64 and VSI_STAT64_T lines with:

#define VSI_STAT64 stat
#define VSI_STAT64_T stat

make & install

Then finish:

make
sudo make install

Tiger

configure

In the GDAL source:

export MACOSX_DEPLOYMENT_TARGET=10.4
export ARCHFLAGS="-arch ppc -arch i386 -arch ppc64 -arch x86_64"
./configure --with-threads --disable-static --without-grass --with-jasper=/usr/local \
--with-libtiff=/usr/local --with-jpeg=/usr/local --with-gif=/usr/local --with-png=/usr/local \
--with-geotiff=internal --with-sqlite3=/usr --with-odbc --with-pcraster=internal \
--with-geos=/usr/local/bin/geos-config --with-static-proj4=/usr/local --with-expat=/usr/local \
--with-xerces --with-xerces-inc=/usr/local/include \
--with-xerces-lib="-L/usr/local/lib -lxerces-c -framework CoreServices" --with-curl --with-python \
--with-macosx-framework CFLAGS="-Os -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk" \
CXXFLAGS="-Os -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk" \
LDFLAGS="-arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk"

If you installed any of these optional packages, add to the configure line:

PostgreSQL –with-pg=/usr/local/pgsql/bin/pg_config
MrSID Geo DSDK –with-mrsid=
and drag the MrSID Geo DSDK folder from the Finder to the Terminal window.
MySQL –with-mysql=/usr/local/mysql/bin/mysql_config
NetCDF –with-netcdf=/usr/local
HDF 4 & 5 –with-hdf4=/usr/local –with-hdf5=/usr/local
OGDI –with-ogdi=/usr/local
CFITSIO –with-cfitsio=/usr/local
DAP –with-dods-root=/usr/local
ECW –with-ecw=/usr/local

port/cpl_config.h

Replace lines:

HOST_FILLORDER line with:

#ifdef __BIG_ENDIAN__
  #define HOST_FILLORDER FILLORDER_MSB2LSB
#else
  #define HOST_FILLORDER FILLORDER_LSB2MSB
#endif

WORDS_BIGENDIAN line with:

#ifdef __BIG_ENDIAN__
  #define WORDS_BIGENDIAN 1
#else
  #undef WORDS_BIGENDIAN
#endif

make & install

Then finish:

make
sudo make install

Frameworks

To build using the frameworks, change the following options as given:

--with-jasper=/Library/Frameworks/UnixImageIO.framework/unix \
--with-libtiff=/Library/Frameworks/UnixImageIO.framework/unix \
--with-jpeg=/Library/Frameworks/UnixImageIO.framework/unix \
--with-gif=/Library/Frameworks/UnixImageIO.framework/unix \
--with-png=/Library/Frameworks/UnixImageIO.framework/unix \
--with-sqlite3=/Library/Frameworks/SQLite3.framework/unix \
--with-geos=/Library/Frameworks/GEOS.framework/Programs/geos-config \
--with-static-proj4=/Library/Frameworks/PROJ.framework/unix \

GRASS

GRASS support must be done as a plugin. This is so that GRASS itself (needed by the plugin) can be compiled after GDAL (needed by GRASS). :!: Note: starting with v6.4, GRASS is particular about its library versions. If you build the GDAL-GRASS plugin for GRASS 6.4, then install and run GRASS 6.5, GRASS will complain because GDAL is still using the GRASS 6.4 libraries.

So, first, install GRASS. The following instructions assume that GRASS is built as an application, with version x.y (ie 6.4).

Combine the files from the GDAL source dirs: frmts/grass and ogr/ogrsf_frmts/grass. It's OK to overwrite the GNUMakefile of one with the other, because you then download this custom GNUMakefile and unzip it and overwrite whichever GNUMakefile is left.

Now, in this merged grass folder:

Leopard

export MACOSX_DEPLOYMENT_TARGET=10.5
make GRASSPREFIX=/Applications/GRASS-x.y.app/Contents/MacOS \
GDALPREFIX=/usr/local PROJPREFIX=/usr/local \
ARCHFLAGS="-arch ppc -arch i386 -arch ppc64 -arch x86_64"

Tiger

export MACOSX_DEPLOYMENT_TARGET=10.5
make GRASSPREFIX=/Applications/GRASS-x.y.app/Contents/MacOS \
GDALPREFIX=/usr/local PROJPREFIX=/usr/local \
ARCHFLAGS="-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"

install

Manually copy the resulting gdal_GRASS.dylib and ogr_GRASS.dylib to the GDAL plugins dir. On a /usr/local install, this will be /usr/local/lib/gdalplugins. For a GDAL framework this is /Library/Application Support/GDAL/PlugIns/$(GDALVER).

macosx/build/gdal.txt (2958 views) · Last modified: 2009/08/12 20:22 by kyngchaos
Copyright © 2004-2009 William Kyngesburye Driven by DokuWiki Recent changes RSS feed