Compiling from Source Code (notes)

grasslogo_vector_small.png
The GRASS Logo

The official instructions from the GRASS Wiki can be found here. My notes on compiling (specific to my requirements) are listed below. Note that you will need to adjust the flags in the configuresteps according to your system.

Special Note when compiling GDAL with the Lizzard Tech DSDK:

  • be sure to use the full path to the DSDK, i.e. don't use shell expansion shortcuts (thanks Hobu)
  • A simple modification to the DSDK source must be performed for a successful build (see notes...)
  1. compile the source (see notes below) on debian this isn't too hard, as most of the dependancies can be met with an 'aptitude install xxx-dev'
  2. get a sample dataset either from the GRASS website, or I would be happy to provide you with some stuff from yolo county (which can of course be obtained for free, from http://gis.ca.gov)
  3. the GRASS Book is a helpfull reference, but it is based on the older branch of GRASS, version 5.3|5.4 ... and thus the vector model is a little out of date. The GRASS mailing list also a great place to get help.

Here are some of my notes on installing it from source:

  1. Install some required packages: these are the names for Debian-based systems
    • compiler and build tools: gcc g77 g++ flex bison m4 make libcfitsio-dev
    • database includes: libsqlite3-dev libmysqlclient14-dev libwrap0-dev (postgresql-includes)
    • GDAL-specific:libhdf4g-dev python-numeric
    • GRASS-specific: libncurses5-dev zlib1g-dev libreadline5-dev libfreetype6-dev libtiff4-dev libpng3-dev tcl8.3-dev tk8.3-dev (glutg3-dev libgle3-dev libgl1-mesa-dev) or (nvidia-glx-dev) fftw-dev
    • X.org requires: libxmu-headers libxmu-dev libxxf86vm-dev libxmuu-dev libxmu-dev
  2. Get and install PROJ4 from source (simple compile)
    • Don't forget the proj-datumgrid-1.4.zip file: unzip in the 'nad' folder before the ./configure step.
  3. Get and install the latest GEOS from source (simple compile)
  4. Get and install the latest GDAL and GDAL-GRASS plugin (relatively simple compile)
## 32-bit mode i7:
export CHOST="i686-pc-linux-gnu"
export CFLAGS="-O2 -pipe -march=native -msse4 -fomit-frame-pointer"
export CXXFLAGS="${CFLAGS}" 

## 64-bit mode PowerPC
#optimization from powerpc64:
export CFLAGS="-mpowerpc64 -O2" 
export CXXFLAGS="-mpowerpc64 -O2"
export FCFLAGS="-O2 -mpowerpc64"
export OBJCFLAGS="-O2 -mpowerpc64"
export FFLAGS="-O2 -mpowerpc64"

Special Note when compiling GDAL with NetCDF Support:

 I usually use the following HDF4 configure script:

./configure --disable-netcdf --disable-fortran --prefix=/usr/local

I usually use the following GDAL configure script:

./configure --with-png=internal --with-jpeg=internal \
--with-gif=internal --with-libtiff=internal --with-geotiff=internal \
--with-netcdf --with-hdf4 \
--without-ogdi --with-python --with-sqlite3 --with-spatialite \
--with-threads=yes --without-grass \
--with-mrsid=/home/dylan/src/Geo_DSDK-6.0.7.1407/ --with-opencl --with-curl

Note that you will need to leave the Lizard Tech DSDK folder in the exact same location for subsequent compilation of GRASS.

5. Checkout the latest development version of GRASS 6 via Subversion:

# check out the software:
svn co http://svn.osgeo.org/grass/grass/branches/develbranch_6 grass6_dev/

# or update a local copy:
svn up

I usually use the following configure script:

./configure --with-tcltk-includes=/usr/include/tcl8.4 \
--with-postgres --without-odbc --with-mysql \
--with-mysql-includes=/usr/include/mysql/ \
--with-freetype --with-freetype-includes=/usr/include/freetype2 \
--with-readline --with-cxx --enable-largefile \
--with-postgres-includes=/usr/local/pgsql/include/ \
--with-postgres-libs=/usr/local/pgsql/lib/ --with-sqlite --with-python \
--with-proj-share=/usr/local/share/proj/ \
--with-cairo --with-pthread --with-wxwidgets

6. Get and install the GDAL-GRASS plugin: GRASS Wiki Page on this topic

Here are the steps that I use:

#link GRASS libs to the /usr/local/lib/ folder
cd /usr/local/lib/ ; sudo ln -s /usr/local/grass-6.5.svn/lib/*.so .
#return to the gdal-grass plugin source directory:
./configure --with-grass=/usr/local/grass-6.5.svn/
#make
make clean && make
#create a gdal-plug-ins folder
sudo mkdir /usr/local/lib/gdalplugins
#copy the compiled plugins to the gdalplugins folder
sudo cp *.so /usr/local/lib/gdalplugins/
#done

7. Finally, you might need to update your /etc/ld.so.conf to include GRASS libs

Here is my /etc/ld.so.conf Don't forget to run ldconfig after changing this file!

---------/etc/ld.so.conf---------------
...
/usr/local/lib
/usr/local/grass-6.5.svn/lib
...
-----------------------------------------