Compile and Install: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(link to SPEC file)
(+Fedora)
Line 544: Line 544:


     bin.$ARCH/grass70 -wx
     bin.$ARCH/grass70 -wx
===== Fedora =====
This is an example how to compile GRASS on a 64bit Fedora system:
  ./configure \
  --enable-64bit \
  --with-cxx \
  --with-libs=/usr/lib64 \
  --with-gdal=/usr/bin/gdal-config \
  --with-proj-share=/usr/share/proj \
  --without-odbc \
  --with-sqlite \
  --with-nls \
  --without-tcltk \
  --with-python=/usr/bin/python-config \
  --without-cairo \
  --without-opengl \
  --with-wxwidgets=/usr/bin/wx-config \
  --with-fftw \
  --with-blas \
  --with-lapack \
  --without-freetype \
  --enable-largefile \
  --with-x \
  --x-includes=/usr/include/X11/


===== RPM SPEC files =====
===== RPM SPEC files =====
* ... can be found in the source code, rpm/ directory,  
* ... can be found in the source code, rpm/ directory,  
* or [http://teodori.org/repository/grass.html openSuSe]
* or [http://teodori.org/repository/grass.html openSuSe]

Revision as of 17:12, 9 December 2010

How to do compilation and installation of GRASS 6?

Here we explain the procedure to compile GRASS from SVN, but it also applies to official GRASS 6 releases.

For installation of precompiled binary packages, see the main Installation Guide.

For detailed information on compilation, please see the INSTALL file in the source code.

Prerequisites

GRASS needs at least two extra libraries: PROJ and GDAL/OGR

Note: if you want to have DBMS support in GDAL (subsequently in GRASS) you have to perform the "Optional" steps below as well.

  • PROJ4 for management of projections (with proj-datumgrid-1.3.zip support)
  • Optional: GEOS
  • Optional: PostgreSQL, mySQL, unixODBC, SQLite (SQLite is needed for QGIS)
  • GDAL/OGR for reading and writing various GIS data formats (interoperability)

You have to install these two libraries first.

It is easiest to obtain a prepackaged version of these libraries (e.g., .rpm; .deb) for your particular operating system and run the corresponding package installation (e.g., rpm -Uhv packagename.rpm; apt-get) in a terminal window. Take care to also install the development packages of these libraries (...-devel packages). If there is no prepackage version, then you will have to download the source code (see links above, source code packages usually ends in .tar.gz or .zip) and compile it (you must have a C compiler installed as part of your operating system). The Web sites show the steps to compile the libraries.


Other libraries needed to run GRASS are listed on the requirements page.

To compile, you will also need the respective "-devel" packages.

Then download GRASS of course.

Generic Compilation and installation procedure

  • It is wise that compilation processes are carried out as a normal user: If you want to get the source code in a place where you do not have write permissions (e.g. in /usr/local/src/) just follow this:
     cd /usr/local/src/ 
     su -c 'mkdir grass6'
     su -c 'chown yourlogin:yourgroup grass6'

Otherwise if you have permissions just continue as a normal user:

     cd /usr/local/src/
     svn checkout ...
  • do a code checkout from the SVN source code repository
checkout the latest GRASS 6.x from SVN (see: [1])
  • in the grass6 directory, you will find the precious INSTALL file, open it with your favourite pager/editor and read it carefully!
  • run configure with parameters to adapt the compile process to your own system. To see what options can be passed to it, run:
./configure --help | less 


It may (!) look like this:

     ./configure \
         --with-cxx \
         --with-sqlite \
         --with-postgres-libs=/usr/include/pgsql/libpq \
         --with-postgres-includes=/usr/include/pgsql \
         --with-freetype \
         --with-freetype-includes=/usr/include/freetype2 \
         --with-motif \
         --with-proj-share=/usr/share/proj

You may have to explicitly state the path for certain packages (i.e., gdal). The Unix 'locate' command will come in handy for finding the path of the package you need (you may have to run locate as root ex: sudo locate gdal-config).

Please note that the paths mentioned may widely vary due to the distribution used. See Platform Specific Notes below.

Depending on your needs it may be a good idea to include debugging hooks.

See GRASS_Debugging#Compile_Time_Setup.
CFLAGS="-ggdb -Wall -Werror-implicit-function-declaration" ./configure ...


At the end of configuration process you should get report not much different from this:

GRASS is now configured for: i686-pc-linux-gnu

Source directory:            /usr/src/grass6
Build directory:             /usr/src/grass6
Installation directory:      /usr/local/grass-6.3.svn
Startup script in directory: ${exec_prefix}/bin
C compiler:                  gcc -g -O2 
C++ compiler:                c++ -g -O2
FORTRAN compiler:            
Building shared libraries:   yes
64bit support:               no

 NVIZ:                       yes

 BLAS support:               no
 C++ support:                yes
 DWG support:                no
 FFMPEG support:             no
 FFTW support:               yes
 FreeType support:           yes
 GDAL support:               yes
 GLw support:                no
 JPEG support:               yes
 LAPACK support:             no
 Large File Support (LFS):   no
 Motif support:              no
 MySQL support:              no
 NLS support:                no
 ODBC support:               no
 OGR support:                yes
 OpenGL(R) support:          yes
 PNG support:                yes
 PostgreSQL support:         yes
 Readline support:           no
 SQLite support:             no
 Tcl/Tk support:             yes
 TIFF support:               yes
 X11 support:                yes
 
  • Let's compile it (takes a little while...)!
     make
  • At the end, you should get report not much different from this:
----------------------------------------------------------------------
Following modules are missing the 'description.html' file in src code:
----------------------------------------------------------------------
GRASS GIS compilation log
-------------------------
Started compilation: Ne kvě 28 13:18:43 CEST 2006
--
Errors in:
--
Finished compilation: Ne kvě 28 13:43:40 CEST 2006
(In case of errors please change into the directory with error and run 'make')
  • If there is any error, change directory to directory with error and run "make" again. Report occuring bug to grass mailing list
  • Once the installation process is finished, you're ready to install GRASS system wide.
     su -c 'make install'
  • enjoy GRASS:
     grass63

What else?

If you want to use QGIS, then also compile the GRASS-GDAL/OGR plugin. This is also useful to access your GRASS-data from other application using GDAL/OGR like thuban.

Compile and install GDAL-GRASS plugin

Platform Specific Notes

Linux

Debian

Read the instructions here:

http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/debian/README.debian
  # first install PROJ, GDAL, etc.
  cd grass64/
  # follow instructions in debian/README.debian
  fakeroot buildpackage
 svn co svn://svn.debian.org/svn/pkg-grass/packages/grass/trunk/

or

 svn co svn://svn.debian.org/svn/pkg-grass/packages/grass/branches/<GRASS Version>
GRASS 6.1 on Debian Sarge
GRASS 6.4 on Debian Lenny

Install needed packages:

 apt-get install flex bison libreadline-dev libncurses5-dev lesstif2-dev debhelper dpatch libtiff4-dev \
         tcl-dev tk-dev libfftw3-dev libxmu-dev libfreetype6-dev autoconf2.13 autotools-dev doxygen \
         libmysqlclient15-dev graphviz libsqlite3-dev python-wxgtk2.8 libcairo2-dev libwxgtk2.8-dev \
         python-dev swig libgdal1-dev  libgdal1-1.5.0 libproj-dev libproj0 proj-data mysql

Configure:

 ./configure \
 --with-cxx \
 --with-sqlite \
 --with-postgres --with-postgres-includes=/usr/include/postgresql \
 --with-mysql --with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib/mysql \
 --with-odbc \
 --with-cairo \
 --with-proj-share=/usr/share/proj \
 --with-tcltk-includes=/usr/include/tcl8.4/ \
 --with-freetype --with-freetype-includes=/usr/include/freetype2 \
 --with-motif --with-fftw --with-nls --with-python

Compile:

 make

Install:

 sudo make install
GRASS 7 on Debian Squeeze

Install needed packages:

apt-get install flex bison libreadline-dev libncurses5-dev lesstif2-dev debhelper dpatch libtiff4-dev \
  tcl-dev tk-dev libfftw3-dev libxmu-dev libfreetype6-dev autoconf2.13 autotools-dev doxygen \
  libmysqlclient-dev graphviz libsqlite3-dev python-wxgtk2.8 libcairo2-dev libwxgtk2.8-dev \
  python-dev swig libgdal1-dev libgdal1-1.6.0 libproj-dev proj-bin libglw1-mesa-dev \
  mysql-client-5.1 mysql-server-5.1 libpq-dev subversion gcc lesstif2-dev \
  zlib1g-dev libproj-dev libtiff4-dev mesa-common-dev libglu1-mesa-dev libcairo2-dev \
  g++ wx-common python-wxgtk2.8 libwxgtk2.8-dev libxt-dev libxmu-headers gettext python-numpy

Download source code:

svn checkout https://svn.osgeo.org/grass/grass/trunk grass_trunk

Configure:

CFLAGS="-g -Wall -Werror-implicit-function-declaration -fno-common -Wextra -Wunused" \
CXXFLAGS="-g -Wall"  \
 ./configure --prefix=/usr/local \
 --with-postgres --with-postgres-includes=/usr/include/postgresql \
 --with-mysql --with-mysql-includes=/usr/include/mysql \
 --with-gdal --with-proj --with-proj-share=/usr/share \
 --with-motif --with-glw --with-nls --with-readline \
 --with-cxx --enable-largefile \
 --with-freetype --with-freetype-includes=/usr/include/freetype2 \
 --with-sqlite \
 --with-odbc --with-cairo --with-python=/usr/bin/python2.6-config --with-wxwidgets \
 --with-tcltk-includes=/usr/include/tcl8.5 --with-tcltk-libs=/usr/lib/tcl8.5 \
 --with-geos --with-pthread

Compile:

 make

Install:

 sudo make install
Ubuntu

The above Debian notes will probably work with Ubuntu as well.

A more specific page towards Ubuntu is being written on.

Ubuntu 6.06, 7.10
  • makegrass.sh is script designed to automate most of the download, configuration and compilation of GRASS 6.x-CVS
    • it is advised use checkinstall (sudo apt-get install checkinstall) instead of make install to keep track of installed software
    • Think twice before using this script. Some users experienced problems such as disabled XGL etc.
  • Here is another of these scripts, it's homemade so probably you'll find the above more useful for production sites.
Ubuntu 7.10 64-bit
  • Compiling latest GRASS source code on a 64-bit machine (with an ATI graphic card) under Ubuntu 7.10 64-bit with support for: 64-bit, SQLite, OpenGL, PYTHON, FFMPEG

(Based on "Ubuntu 6.06 LTS - GRASS 6.1 Compilation Script" by David Finlayson) Assuming it is the first time attempting to compile GRASS' source code & installing SVN, PROJ, GDAL/OGR

Preparation

sudo apt-get update && sudo apt-get upgrade
  • install dependencies for compiling (in general) and dependencies for GRASS: PROJ, GDAL/OGR
sudo apt-get install grass build-essential flex bison libncurses5-dev zlib1g-dev \
libjpeg62-dev libgdal1-dev libtiff4-dev libgcc1 libpng12-dev tcl8.4-dev tk8.4-dev fftw3-dev \
libfreetype6-dev libavcodec-dev libxmu-dev gdal-bin libreadline5 libreadline5-dev \
make python-dev python-wxversion swig
  • install SQLite
sudo apt-get install sqlite3 libsqlite3-dev
  • install SVN
sudo apt-get install subversion
  • create a directory as a simple user where source code(s) are going to be stored (in our example we use a directory called src under /usr/local)
sudo mkdir /usr/local/src
  • grant rwx (read-write-execute) permissions for our userid/ groupid on the directory (replace words userid and groupid with real userid):
sudo chown userid:groupid /usr/local/src
sudo chmod ug+rwx /usr/local/src
  • download latest source code from GRASS SVN repository in a directory on the system (e.g. /usr/local/src)
svn checkout https://svn.osgeo.org/grass/grass/trunk grass_trunk
  • Above command places GRASS' source code in /usr/local/src/grass_trunk. In case of a subsequent update use the command: svn up from within the grass_trunk directory

Before attempting to compile GRASS, READ section (C) in the INSTALL file located in the main directory of GRASS source code entitled: (C) COMPILATION NOTES for 64bit platforms


  • installing FFTW3 if not already on system
sudo apt-get install fftw3 fftw3-dev

FFMPEG

Note: Back in Ubuntu 7.10, installing ffmpeg through the repositories wouldn't work with grass. The following steps were successfully used.

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
  • install dependencies
sudo apt-get install liblame-dev libfaad2-dev libfaac-dev libxvidcore4-dev \
     liba52-0.7.4 liba52-0.7.4-dev libx264-dev libdts-dev checkinstall \
     build-essential subversion
  • guide to ffmpeg directory
cd ffmpeg

if necessary: make distclean before configuration (look at notes below)

  • configuration (note: the configuration parameter "--enable-pp" does not work anymore)
# configure FFMPEG
./configure --enable-gpl --enable-libvorbis --enable-libtheora \
            --enable-liba52 --enable-libdc1394 --enable-libgsm \
            --enable-libmp3lame --enable-libfaad --enable-libfaac \
            --enable-libxvid --enable-pthreads --enable-libx264 \
            --enable-shared
  • compilation
make
  • installation on /usr/local/bin -- important to remember when configuring GRASS' source code for compilation
sudo checkinstall

Go for GRASS!

  • in our example we used the /usr/local/src directory to store GRASS' source code, so:
cd /usr/local/src/grass_trunk
  • configuration
 CFLAGS="-g -Wall" ./configure --enable-64bit \
       --with-libs=/usr/lib64 --with-cxx --with-freetype=yes \
       --with-postgres=no --with-sqlite=yes --enable-largefile=yes \
       --with-tcltk-includes=/usr/include/tcl8.4 \
       --with-freetype-includes=/usr/include/freetype2 \
       --with-opengl-libs=/usr/include/GL --with-readline \
       --with-python=yes --with-ffmpeg=yes \
       --with-ffmpeg-includes=/usr/local/include/ffmpeg
  • if OpenGL fails then maybe it is necessary to link glxATI.h with glx.h and re-run the configuration
cd /usr/include/GL
sudo ln glxATI.h glx.h
  • compilation
make
  • compilation is expected to end with a statement similar to the following:
Started compilation: Wed Feb 27 00:24:36 CET 2008
--
Errors in:
No errors detected.
  • installation
sudo checkinstall
  • launch 64-bit GRASS.6.4.svn
grass64

Notes

  • in case of errors in future compilation attempts, remember to remove program binaries with
make clean
  • and the files created with the "configuration" from previous compilations with
make distclean
Ubuntu 8.04 and 9.04
Mandriva

Installation of dependencies (urpmi will ask you a few more):

Mandriva 2009: (take out the '64' everywhere if you are on 32bit)

 # as root
   urpmi flex bison zlib-devel tiff-devel png-devel tcl-devel tk-devel sqlite3-devel \
         mesagl1-devel mesaglu1-devel lib64xmu6-devel gcc-c++ swig gettext \
         lib64wxgtk2.8 lib64wxgtk2.8-devel lib64wxgtkgl2.8 wxgtk2.8 \
         lib64wxPythonGTK2.8 lib64wxPythonGTK2.8-devel wxPythonGTK wxPythonGTK-wxversion
   exit

Mandriva 2010: (take out the '64' everywhere if you are on 32bit) - see also SPEC file

 # as root
   # installation of PROJ and GDAL
   urpmi proj proj-devel gdal gdal-devel gcc-gfortran lib64openssl1.0.0 \
         lib64openssl1.0.0-devel postgresql8.4-devel lib64pq8.4

   # installation of compilation environment
   urpmi flex bison zlib-devel tiff-devel png-devel tcl-devel tk-devel sqlite3-devel \
         lib64mesagl1-devel lib64mesaglu1-devel lib64xmu6-devel gcc-c++ swig gettext \
         lib64jpeg-devel lib64wxgtk2.8 lib64wxgtk2.8-devel lib64wxgtkgl2.8 wxgtk2.8 \
         lib64wxPythonGTK2.8 lib64wxPythonGTK2.8-devel wxPythonGTK wxPythonGTK-wxversion
   exit

Then, to configure GRASS, run (64 bit stuff optional of course):

 #  as user
 ./configure \
   --enable-64bit --with-libs=/usr/lib64 \
   --with-cxx \
   --with-gdal=/usr/local/bin/gdal-config \
   --with-sqlite \
   --with-nls \
   --with-python \
   --with-wxwidgets=/usr/lib/wxPython/bin/wx-config \
   --with-fftw \
   --with-ffmpeg --with-ffmpeg-includes="/usr/include/libav* /usr/include/libpostproc /usr/include/libswscale" \
   --with-motif \
   --with-mysql --with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib64 \
   --with-freetype --with-freetype-includes=/usr/include/freetype2 \
   --enable-largefile
  # compilation (use -j2 ior -j4 parameter on multi-core CPUs to accelerate):   
   make

Installation:

   su
   # this will install into /usr/local/
   make install
   exit
CentOS

Note: CentOS 5 comes with Python 2.4 which lacks python-config, hence two extra tweaks are needed.

Preparation:

 yum install flex bison zlib-devel  tcl-devel tk-devel gcc-c++ swig gettext \
             libtiff-devel libpng-devel sqlite-devel libjpeg-devel \
             mesa-libGL-devel mesa-libGLU-devel mesa-libGLw-devel \
             mesa-libOSMesa-devel libXmu-devel python-devel gtk2-devel\
             ncurses-devel postgresql-devel


Compile and install PROJ4:

# get source code and unpack:
wget http://download.osgeo.org/proj/proj-4.7.0.tar.gz
tar xvfz proj-4.7.0.tar.gz 
rm -f proj-4.7.0.tar.gz 
cd proj-4.7.0/

# get and install datum files into right directory:
cd nad/
wget http://download.osgeo.org/proj/proj-datumgrid-1.5.zip
unzip proj-datumgrid-1.5.zip
rm -f proj-datumgrid-1.5.zip
cd ..

# configure and compile
sh configure
make -j4

# install (may require "root" permissions, use "su"):
make install

Compile and install GDAL:

# get source code and unpack:
wget http://download.osgeo.org/gdal/gdal-1.6.3.tar.gz
tar xvfz gdal-1.6.3.tar.gz 
rm -f gdal-1.6.3.tar.gz 
cd gdal-1.6.3/

# configure and compile
sh configure
make -j4

# install (may require "root" permissions, use "su"):
make install

# add /usr/local/lib/ to LD_LIBRARY_PATH, requires "root" permissions:
su - 
echo "/usr/local/lib" > /etc/ld.so.conf.d/gdal.conf
ldconfig
exit

# test installation by running
gdalinfo


GRASS 7 compilation and installation, here 64bit example:

1. Download wxGTP and wxPython:

 wget http://packages.sw.be/wxPython/wxPython-2.8.9.1-1.el5.rf.x86_64.rpm
 wget http://packages.sw.be/wxPython/wxPython-devel-2.8.9.1-1.el5.rf.x86_64.rpm
 wget http://packages.sw.be/wxGTK/wxGTK-2.8.9-1.el5.rf.x86_64.rpm
 wget http://packages.sw.be/wxGTK/wxGTK-devel-2.8.9-1.el5.rf.x86_64.rpm

 # Install:
 rpm -Uhv wxPython-2.8.9.1-1.el5.rf.x86_64.rpm wxPython-devel-2.8.9.1-1.el5.rf.x86_64.rpm \
          wxGTK-2.8.9-1.el5.rf.x86_64.rpm wxGTK-devel-2.8.9-1.el5.rf.x86_64.rpm


2. Download and configure GRASS 7 (suggestion: save this as script). Note that PROJ4 and GDAL must be compiled first:

./configure \
 --with-libs=/usr/lib64 \
 --with-cxx \
 --without-ffmpeg \
 --with-gdal=/usr/local/bin/gdal-config \
 --without-odbc \
 --with-sqlite \
 --with-postgres \
 --without-mysql \
 --with-nls \
 --with-python \
 --with-cairo \
 --with-wxwidgets=/usr/bin/wx-config \
 --without-fftw \
 --with-freetype --with-freetype-includes=/usr/include/freetype2 \
 --enable-largefile \
 --with-pthread

3. Hack the Makefile of GRASS-SWIG since python-config isn't there (add one line without the '+'):

 svn diff swig/
 Index: swig/python/Makefile
 ===================================================================
 --- swig/python/Makefile        (revision 38916)
 +++ swig/python/Makefile        (working copy)
 @@ -36,6 +36,7 @@
  EXTRA_SWIG = ../include/python/my_typemaps.i ../include/python/common.i
  SWIGFLAGS = $(INC) -I../include/python -outdir .
  EXTRA_CFLAGS = $(PYMOD_CFLAGS)
 +EXTRA_LIBS = -lpython2.4
  EXTRA_CLEAN_FILES := $(foreach M,$(MODULES),$(M)_wrap.o $(M)_wrap.c $(M).pyc $(M).py _$(M).so)
  CLEAN_SUBDIRS = NumPtr

4. Add manually the path to the python include directory since python-config isn't there:

  # edit include/Make/Platform.make
  # and add manually the line

  PYTHONINC           = -I/usr/include/python2.4

5. Compile

   make
  or on multicore:
   make -j4

6. Either install with "make install" or run directly from compile directory (substitute ARCH with i586 or x86_64):

   bin.$ARCH/grass70 -wx
Fedora

This is an example how to compile GRASS on a 64bit Fedora system:

 ./configure \
  --enable-64bit \
  --with-cxx \
  --with-libs=/usr/lib64 \
  --with-gdal=/usr/bin/gdal-config \
  --with-proj-share=/usr/share/proj \
  --without-odbc \
  --with-sqlite \
  --with-nls \
  --without-tcltk \
  --with-python=/usr/bin/python-config \
  --without-cairo \
  --without-opengl \
  --with-wxwidgets=/usr/bin/wx-config \
  --with-fftw \
  --with-blas \
  --with-lapack \
  --without-freetype \
  --enable-largefile \
  --with-x \
  --x-includes=/usr/include/X11/


RPM SPEC files
Zaurus

... see here for instructions

Mac OSX

Solaris

10 SPARC/i86pc
  • get gcc compiler and tools. There are several sources: Solaris Companion CD (SFW pkg, installs in /opt/sfw/), Blastwave ([2], CSW pkg, installs in /opt/csw/) or Sunfreeware ([3], SMC pkg, installs in /usr/local/).

Needed Packages from Sunfreeware: SMCbinut, SMCbison, SMCcoreu, SMCfindu, SMCflex, SMCgawk, SMCgcc, SMCgrep, SMCgzip, SMCless, SMClibt, SMClicon, SMCmake, SMCncurs, SMCproj, SMCsed, SMCtar, SMCtcl, SMCtiff, SMCtk, SMCunzip, SMCzlib.

  • compile and install fftw-library ([4]). You need to re-compile the library with:
     ./configure --with-pic --enable-shared; make ; make install. 

The pre-built packages don't work.

  • compile and install gdal library (see documentation of gdal, [5]).
  • compile and install any additional libraries (e. g. GEOS, [6]).
  • set compiler flags and path. e. g.:
     # on ultra-sparc machine:
     CFLAGS="-O3 -mcpu=v9"
     CXXFLAGS="-O3 -mcpu=v9"
     PATH="/usr/local/bin:/opt/sfw/bin:/usr/ccs/bin:/usr/bin:/usr/sbin"
     export CFLAGS CXXFLAGS PATH

Path has to be changed for the packages (Sunfreeware: /usr/local/bin, Solaris Companion: /opt/sfw/bin, Blastwave: /opt/csw/bin).

  • Next configure, e. g.:
     ./configure --with-postgres-includes=/usr/include/pgsql/ \
     --with-postgres-libs=/usr/lib --with-postgres=yes \
     --with-includes=/usr/local/include/ncurses

If you use n(ew)curses, you have to include the path /usr/local/include/ncurses.

then:

     make
     su
     make install

If the shared libraries are not found at runtime of the modules, use 'crle' to add the paths of the libraries for the dynamic linker, e. g. as root:

     crle -l /lib:/usr/lib:/usr/local/lib:/opt/sfw/lib:/usr/X11/lib

Be careful not to omit a library path, the system may be unusable if you forget the /lib path.

AIX

Mike wrote:

After attempting all the suggestions, I finally used
--disable-shared on the configure command, and all but
a handful of modules successfully compiled. I was able to
individually address the ones that failed through Makefile
edits and several small source code/header file edits.

The environment variables and configure command that worked were:

export PATH=/usr/local/bin:/opt/freeware/bin:$PATH
export OBJECT_MODE=64
export LIBICONV=/opt/freeware
export CC="xlc_r -q64"
export CFLAGS="-O -qstrict"
export CXX="xlC_r -q64"
export CXXFLAGS="-O -qstrict"
export AR="ar -X64"
export F77="xlf_r -q64"
export CPPFLAGS="-I/afs/isis/pkg/libpng/include -I/usr/local/include -I$LIBICONV/include -I/usr/lpp/X11/include/X11"
export LDFLAGS="-L/usr/local/lib -L$LIBICONV/lib -L/usr/lib -L/usr/X11R6/lib -lc"

./configure --prefix=/afs/isis/pkg/grass-6.4.0 \
  --enable-64bit \
  --disable-shared \
  --with-includes="/usr/include/fontconfig /usr/include/X11 /usr/include/X11/Xft /usr/include/X11/ext" \
  --x-includes=/usr/include/X11 \
  --x-libraries=/usr/X11R6/lib \
  --with-fftw-includes=/afs/isis/pkg/fftw-3.2.2/include \
  --with-fftw-libs=/afs/isis/pkg/fftw-3.2.2/lib \
  --with-gdal=/afs/isis/pkg/gdal/bin/gdal-config \
  --with-proj-includes=/afs/isis/pkg/proj/include \
  --with-proj-libs=/afs/isis/pkg/proj/lib \
  --with-proj-share=/afs/isis/pkg/proj/share/proj \
  --with-tcltk-includes=/usr/local/include \
  --with-tcltk-libs=/usr/local/lib \
  --with-opengl-includes=/usr/include/GL

MS-Windows

MS-Windows/Cygwin

... see here (should be moved to the Wiki)

MS-Windows/native
Compile

See also WinGRASS Current Status for latest updates.

Common problems and solutions

During compilation, error can occur if certain packages are not installed. Here a list of problems with solution:

  • error: X11/Xlib.h: No such file or directory
    • this suggests that you don't have the X headers installed
    • Solution: Install the libx11-dev package

Optimization

GCC and other compilers support optimization

If you would like to set compiler optimisations, for a possibly faster binary, type (don't enter a ";" anywhere):

       CFLAGS=-O ./configure

or,

       setenv CFLAGS -O
       ./configure

whichever works on your shell. Use -O2 instead of -O if your compiler supports this (note: O is the letter, not zero). Using the "gcc" compiler, you can also specify processor specific flags (examples, please suggest better settings to us):

 CFLAGS="-mcpu=athlon -O2" # AMD Athlon processor with code optimisations
 CFLAGS="-march=amdfam10"  # AMD Phenom II X4 64bit processor with gcc >=4.3
 CFLAGS="-mcpu=pentium"    # Intel Pentium processor
 CFLAGS="-mcpu=pentium4"   # Intel Pentium4 processor
 CFLAGS="-O2 -msse -msse2 -mfpmath=sse -minline-all-stringops" # Intel XEON 64bit processor
 CFLAGS="-mtune=nocona -m64 -minline-all-stringops"            # Intel Pentium 64bit processor


To find out optional CFLAGS for your platform, enter:

 gcc -dumpspecs

See also: http://gcc.gnu.org/

A real fast GRASS version (and small binaries) will be created with LDFLAGS set to "stripping" (but this disables debugging):

 CFLAGS="-O2 -mcpu=<cpu_see_above> -Wall" LDFLAGS="-s" ./configure

Configure options and their meanings

For configure there are many options and some GRASS modules are built only if some options are set. Here are listed common configuration options with short explanation.

  • --prefix=/path - Sets path where GRASS will be installed. GRASS will reside in /path/grass-version.
  • --enable-largefile - Enables large (>2Gb on 32bit systems) support. For current large file support status look at Large File Support page.
  • --with-cxx - Enables compilation of C++ code. Required for r.terraflow module.
  • --with-readline - Enables readline support. If readline is enabled, you can use its history/editing facilities when entering r.mapcalc expressions on stdin.
  • --with-glw - Enables GLw support. The GLw library provides OpenGL "canvas" widgets for Athena and Motif.
That switch is unnecessary for normal compilation. It's only
required for r3.showdspf, which isn't normally built; if you 
want it, you have build it manually 
(e.g. "make -C raster3d/r3.showdspf").
As similar functionality is now provided by NVIZ, r3.showdspf
is deprecated.
r3.showdspf uses the Motif widget (so you also need a 
Motif library, e.g. Lesstif or OpenMotif).
Glynn Clements at GRASS-user mailing list

Parallelized compilation on multi-core CPUs

You can dramatically accelerate the compilation of the GRASS code with the -j flag of "make" if you have a multi-core CPU system. This determines the maximum number of jobs to have running at once, so cores don't have to sit idle waiting for jobs on other cores to complete. A good rule of thumb for this value is number_of_cores * 1.5, but note that setting any higher than the actual number of cores will only affect the timing slightly. For example, on a dual-core processor:

 make -j 4


Addons

GRASS-GDAL plugin

Compiled C modules

Requirements:

Either:

  • a binary GRASS package, or
  • source code which has been prepared with:
   ./configure [opionally flags]
   make libs

Each of the addon modules should come with a Makefile. To compile it, just run:

   make MODULE_TOPDIR=/path/to/grass64/

If using Bash it may be useful to set that up as an alias:

   alias gmake64='make MODULE_TOPDIR=/path/to/grass64/'

Installation (perhaps requires "sudo"):

   make MODULE_TOPDIR=/path/to/grass64/ install

Note: Compiled addons may require a re-compilation if you changed/updated your GRASS standard binaries.

If binary comes with a -dev package

(work in progress, this text states how it eventually will be :) Nowadays one does not need to the source code, nor compiling GRASS by oneself to be able to add add-ons. On Debian, you can just install the grass-dev package and then run:

make MODULE_TOPDIR=/usr/lib/grass64/ INST_DIR=/usr/lib/grass64/

The grass-dev package essentially provides GRASS's include header files and Make configuration files.

Scripts

If the addon module is a script, it is sufficient to copy it into the (GRASS binaries) path somewhere. Alternatively, install addons into a separate GRASS addons binaries/scripts directory which is easier to maintain. It avoids getting clobbered every time you reinstall GRASS. To use these separately stored scripts, set and export the GRASS_ADDON_PATH environment variable before starting GRASS and it will automatically be added to the module search path (see the variables help page). To simplify this, do for example:

# add in $HOME/.bashrc:
GRASS_ADDON_PATH=/usr/local/grass/addons/
export GRASS_ADDON_PATH

Make sure that the script is executable, then just call it in GRASS typing the filename. Python scripts need to be called writing the extension as well, like:

GRASS 6.5.svn (spearfish60):~ > v.krige.py