Compile and Install: Difference between revisions
(→Mac OSX: Fink) |
m (→Linux: Grammar correction: "cames" to "comes") |
||
Line 153: | Line 153: | ||
==== Linux ==== | ==== Linux ==== | ||
Linux | Linux comes in various flavours, i.e. distributions. | ||
===== Debian ===== | ===== Debian ===== |
Revision as of 15:47, 31 May 2017
Disclaimer: This page explains how to turn the GRASS GIS source code into an installable binary package ("compilation") for different operating systems. If you just want to get ready-to-use binaries, go here, otherwise read on...
How to do compilation and installation of GRASS GIS?
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
Extra libraries
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 (see below how to get them precompiled for your system).
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.
Download GRASS GIS source code
Then download the GRASS GIS source code 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.
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 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:
grass64
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 GRASS and QGIS with GDAL/OGR Plugin (enables QGIS to read GRASS data directly)
Compile and install GDAL-GRASS plugin
Platform Specific Notes
Linux
Linux comes in various flavours, i.e. distributions.
Debian
Read the instructions here:
# first install PROJ, GDAL, etc. cd grass64/ # follow instructions in debian/README.debian fakeroot buildpackage
- Official DebianGIS packaging control files:
http://svn.debian.org/viewsvn/pkg-grass/packages/grass/ 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>
Available on git server:
git://git.debian.org/git/pkg-grass/grass.git
http://anonscm.debian.org/cgit/pkg-grass/grass.git/
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 libgdal1-dev libgdal1-1.5.0 libproj-dev libproj0 proj-bin proj-data mysql
- Important: avoid using CFLAGS="... -Werror-implicit-function-declaration" (also on later Debian versions), see trac #1684
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 \ --with-x --x-libraries=/usr/lib/x86_64-linux-gnu
Compile:
make
Install:
sudo make install
GRASS 6.4 on Debian Jessie
Install needed packages:
apt-get install flex bison debhelper dpatch autoconf2.13 autotools-dev \ python-dev g++ gcc gettext graphviz libcairo2-dev libfftw3-dev tcl-dev tk-dev \ libfreetype6-dev libgdal1h libgdal1-dev libglu1-mesa-dev libglw1-mesa-dev \ libncurses5-dev libreadline-dev libsqlite3-dev libtiff5-dev \ libwxgtk3.0-dev libxmu-dev libxmu-headers libxt-dev mesa-common-dev \ libproj-dev proj-bin proj-data python-numpy python-wxgtk3.0 subversion wx-common zlib1g-dev \ netcdf-bin libnetcdf-dev libatlas-dev libgegl-dev doxygen postgresql mysql-server \ libgeotiff-dev libblas-dev libgeotiff-epsg libxmu-dev libxt-dev libx11-dev
- Important: avoid using CFLAGS="... -Werror-implicit-function-declaration" (also on later Debian versions), see trac #1684
Configure:
./configure \ --with-cxx \ --with-sqlite \ --with-postgres \ --with-odbc \ --with-cairo \ --with-geos \ --with-proj-share=/usr/share/proj \ --with-tcltk-includes=/usr/include/tcl8.6/ \ --with-mysql --with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib/mysql \ --with-freetype --with-freetype-includes=/usr/include/freetype2 \ --with-motif \ --with-fftw \ --with-nls \ --with-postgres-includes=/usr/include/postgresql \ --with-python \ --with-x --x-libraries=/usr/lib/x86_64-linux-gnu
Compile:
make
Install:
sudo make install
GRASS 7 on Debian Squeeze
Install needed packages:
apt-get install flex bison debhelper dpatch autoconf2.13 autotools-dev python-dev \ g++ gcc gettext graphviz libcairo2-dev libfftw3-dev libfreetype6-dev \ libgdal1 libgdal1-dev libglu1-mesa-dev libglw1-mesa-dev \ libncurses5-dev libproj-dev libreadline-dev libsqlite3-dev libtiff4-dev \ libwxgtk2.8-dev libxmu-dev libxmu-headers libxt-dev mesa-common-dev \ proj-bin proj-data python-numpy python-wxgtk2.8 subversion wx-common zlib1g-dev
Download source code:
svn checkout https://svn.osgeo.org/grass/grass/trunk grass_trunk
Configure:
cd grass_trunk/ CFLAGS="-Wall -Werror-implicit-function-declaration -fno-common -Wextra -Wunused" \ CXXFLAGS="-Wall" \ ./configure --prefix=/usr/local \ --with-gdal --with-proj --with-proj-share=/usr/share \ --with-glw --with-nls --with-readline \ --without-tcltk \ --with-cxx \ --enable-largefile \ --with-freetype --with-freetype-includes=/usr/include/freetype2 \ --with-sqlite \ --with-cairo --with-python=/usr/bin/python2.6-config --with-wxwidgets \ --with-geos --with-pthread
Compile:
make
Install:
sudo make install # installs as /usr/local/bin/grass71
GRASS 7 on Debian Wheezy
Install needed packages:
# note: cmake and libboost-all-dev only needed for optional libLAS sudo apt-get install cmake libboost-all-dev sudo apt-get install flex bison debhelper dpatch autoconf2.13 autotools-dev \ python-dev g++ gcc gettext graphviz libcairo2-dev libfftw3-dev libfreetype6-dev \ libgdal1 libgdal1-dev libglu1-mesa-dev libglw1-mesa-dev libncurses5-dev libproj-dev \ libreadline-dev libtiff4-dev libwxgtk2.8-dev libxmu-dev libxmu-headers \ libxt-dev mesa-common-dev proj-bin proj-data python-numpy python-wxgtk2.8 subversion wx-common \ zlib1g-dev netcdf-bin libatlas-dev libgegl-dev opencl-headers ocl-icd-libopencl1 \ libsqlite3-dev postgresql python-sphinx python-gdal
Download and Install libLAS
wget http://download.osgeo.org/liblas/libLAS-1.7.0.tar.gz tar -zxvf libLAS-1.7.0.tar.gz cd libLAS-1.7.0/ mkdir makefiles cd makefiles cmake -G "Unix Makefiles" ../ make sudo make install sudo ldconfig cd ../..
Download of GRASS GIS 7 source code:
wget http://grass.osgeo.org/grass70/source/grass-7.0.0.tar.gz tar -zxvf grass-7.0.0.tar.gz
Configure:
cd grass-7.0.0 CFLAGS="-g -Wall -Werror-implicit-function-declaration -fno-common -Wextra -Wunused" CXXFLAGS="-g -Wall" \ ./configure \ --prefix=/usr/local \ --with-gdal \ --with-proj --with-proj-share=/usr/share \ --with-glw --with-nls --with-readline \ --with-cxx --enable-largefile \ --with-freetype --with-freetype-includes=/usr/include/freetype2 \ --with-sqlite --with-cairo --with-python=/usr/bin/python-config \ --with-wxwidgets --with-geos --with-blas \ --with-lapack-includes=/usr/lib/lapack --with-liblas=yes \ --with-netcdf=/usr/bin/nc-config --with-odbc=yes \ --with-openmp=yes --with-pthread=yes --with-postgres=yes \ --with-postgres-includes=/usr/include/postgresql \ --with-postgres-libs=/usr/lib/postgresql # --with-mysql=yes --with-mysql-includes=/usr/include/mysql \ # --with-mysql-libs=/usr/lib/mysql \
GRASS GIS 7 is now configured (example):
Source directory: /home/user/grass-7.0.0 Build directory: /home/user/grass-7.0.0 Installation directory: ${prefix}/grass-7.0.0 Startup script in directory:${exec_prefix}/bin C compiler: gcc -g -Wall -Werror-implicit-function-declaration -fno-common -Wextra -Wunused C++ compiler: c++ -g -Wall Building shared libraries: yes OpenGL platform: X11 MacOSX application: no MacOSX architectures: MacOSX SDK: BLAS support: yes C++ support: yes Cairo support: yes DWG support: no FFTW support: yes FreeType support: yes GDAL support: yes GEOS support: yes LAPACK support: no Large File support (LFS): yes libLAS support: yes MySQL support: no NetCDF support: yes NLS support: yes ODBC support: yes OGR support: yes OpenCL support: no OpenGL support: yes OpenMP support: yes PNG support: yes POSIX thread support: yes PostgreSQL support: yes Readline support: yes Regex support: yes SQLite support: yes TIFF support: yes wxWidgets support: yes X11 support: no
Compile:
make -j2
Install:
sudo make install # installs as /usr/local/bin/grass70
Launch:
grass70
GRASS 7 on Debian Jessie
Install needed packages:
sudo apt-get install cmake libboost-all-dev flex bison debhelper dpatch autoconf2.13 \ autotools-dev python-dev g++ gcc gettext graphviz libcairo2-dev libfftw3-dev \ libfreetype6-dev libgdal1h libgdal1-dev libglu1-mesa-dev libglw1-mesa-dev \ libncurses5-dev libproj-dev libreadline-dev libsqlite3-dev libtiff5-dev \ libwxgtk3.0-dev libxmu-dev libxmu-headers libxt-dev mesa-common-dev \ proj-bin proj-data python-numpy python-wxgtk3.0 subversion wx-common zlib1g-dev \ netcdf-bin libnetcdf-dev libgegl-dev doxygen python-sphinx \ postgresql libgeotiff-dev libblas-dev mysql-server \ libatlas-dev libblas-dev liblapack3gf liblapack-dev # opencl-headers ocl-icd-libopencl1 liblas-bin liblas-c-dev python-gdal
Download and compile libLAS (or simply install 'liblas-c-dev ', see above):
wget http://download.osgeo.org/liblas/libLAS-1.8.0.tar.bz2 tar xjf libLAS-1.8.0.tar.bz2 mkdir libLAS-1.8.0/makefiles cd libLAS-1.8.0/makefiles cmake -G "Unix Makefiles" ../ make sudo make install
Download and compile GRASS 7:
# (check there for later version) wget http://grass.osgeo.org/grass70/source/grass-7.0.0.tar.gz tar xzfv grass-7.0.0.tar.gz cd grass-7.0.0 CFLAGS="-g -Wall -Werror-implicit-function-declaration -fno-common -Wextra -Wunused" \ CXXFLAGS="-g -Wall" \ ./configure \ --prefix=/usr/local \ --with-gdal --with-proj --with-proj-share=/usr/share \ --with-glw --with-nls --with-readline \ --with-cxx --enable-largefile \ --with-freetype --with-freetype-includes=/usr/include/freetype2 \ --with-sqlite --with-cairo --with-python=/usr/bin/python-config \ --with-wxwidgets --with-geos \ --with-blas --with-blas-includes=/usr/include/atlas/ \ --with-lapack --with-lapack-includes=/usr/include/atlas/ \ --with-netcdf=/usr/bin/nc-config --with-odbc=yes \ --with-openmp=yes --with-pthread=no --with-postgres=yes \ --with-postgres-includes=/usr/include/postgresql \ --with-postgres-libs=/usr/lib/postgresql \ --with-mysql=yes --with-mysql-includes=/usr/include/mysql \ --with-mysql-libs=/usr/lib/mysql make -j2
Install:
sudo make install # installs as /usr/local/bin/grass70
GRASS 7 on Debian Stretch
(Updated from above with package changes required for Debian Stretch)
Install needed packages (Updated 29 November 2016 to switch libgdal1i, libgdal1-dev to libgdal20 and libgdal-dev):
apt-get install cmake libboost-all-dev flex bison debhelper dpatch autoconf2.13 autotools-dev \ python-dev g++ gcc gettext graphviz libcairo2-dev libfftw3-dev libfreetype6-dev libgdal20 \ libgdal-dev libglu1-mesa-dev libglw1-mesa-dev libncurses5-dev libproj-dev libreadline-dev \ libsqlite3-dev libtiff5-dev libwxgtk3.0-dev libxmu-dev libxmu-headers libxt-dev mesa-common-dev \ proj-bin proj-data python-numpy python-wxgtk3.0 subversion wx-common zlib1g-dev netcdf-bin \ libnetcdf-dev libgegl-dev doxygen python-sphinx postgresql libgeotiff-dev libblas-dev \ mysql-server libatlas-dev libblas-dev liblapack3 liblapack-dev opencl-headers ocl-icd-libopencl1 \ liblas-bin liblas-c-dev python-gdal
Download and unpack source code or fetch from SVN: https://grass.osgeo.org/download/software/sources/
Configuration:
CFLAGS="-g -Wall -Werror-implicit-function-declaration -fno-common -Wextra -Wunused" \ CXXFLAGS="-g -Wall" \ ./configure \ --prefix=/usr/local \ --with-gdal --with-proj --with-proj-share=/usr/share \ --with-glw --with-nls --with-readline \ --with-cxx --enable-largefile \ --with-freetype --with-freetype-includes=/usr/include/freetype2 \ --with-sqlite --with-cairo --with-python=/usr/bin/python-config \ --with-wxwidgets --with-geos \ --with-blas --with-blas-includes=/usr/include/atlas/ \ --with-lapack --with-lapack-includes=/usr/include/atlas/ \ --with-netcdf=/usr/bin/nc-config --with-odbc=yes \ --with-openmp=yes --with-pthread=no --with-postgres=yes \ --with-postgres-includes=/usr/include/postgresql \ --with-postgres-libs=/usr/lib/postgresql \ --with-mysql=yes --with-mysql-includes=/usr/include/mysql \ --with-mysql-libs=/usr/lib/mysql
Compile:
make -j2
Install:
make install
Ubuntu
There is a dedicated page on how to Compile the GRASS GIS source code & install it in Ubuntu.
Linux Mint
The detailed compilation guide for Ubuntu may just work. Here is a short guide for Mint:
sudo apt-get install build-essential flex make bison gcc libgcc1 g++ \ cmake ccache python python-dev python-qt4 python-qt4-dev python-opengl \ python-wxversion python-wxtools python-wxgtk2.8 python-dateutil \ libgsl0-dev python-numpy wx3.0-headers wx-common libwxgtk3.0-dev \ libwxgtk3.0-dbg libwxbase3.0-dev libwxbase3.0-dbg \ zlib1g-dev gettext libtiff-dev libpnglite-dev \ libcairo2 libcairo2-dev sqlite3 libsqlite3-dev libpq-dev libreadline6 \ libreadline6-dev libfreetype6-dev txt2tags libfftw3-3 libfftw3-dev \ lsb-desktop libapt-pkg-perl resolvconf libjasper-dev subversion \ libswscale-dev checkinstall libglu1-mesa-dev libxmu-dev \ libproj-dev proj-bin proj-data gdal-bin python-gdal libgdal1-dev # GRASS GIS 6 only: libncurses5-dev tcl8.5-dev tk8.5-dev # Extra: ffmpeg ffmpeg2theora libffmpegthumbnailer-dev libavcodec-dev libavformat-dev CFLAGS="-Wall" ./configure --with-cxx --with-gdal \ --with-proj --with-proj-share=/usr/share/proj/ \ --with-geos --without-postgres \ --with-nls --with-opengl-includes=/usr/include/GL/ \ --with-fftw --with-freetype \ --with-freetype-includes=/usr/include/freetype2 --with-sqlite \ --with-python=/usr/bin/python2.7-config --with-wx=/usr/bin/wx-config \ --with-wxwidgets --with-cairo --enable-largefile # G6: --with-tcltk-includes=/usr/include/tcl8.5/ \ make sudo make install
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++ 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++ gettext \ 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
Enterprise Linux
Enterprise Linux (EL) and derivatives (that is, Red Hat Enterprise Linux, CentOS and Scientific Linux) is a popular and robust platform for servers and computing-heavy workstations, and is therefore a good fit for GIS specific requirements.
See: http://wiki.osgeo.org/wiki/Enterprise_Linux_GIS
Scientific Linux
See Centos
CentOS
You first need to add the EPEL repository for PROJ.4 and GDAL, see here
Preparation Centos 5 (old):
yum install epel-release # Note: CentOS 5 comes with Python 2.4 which lacks python-config, hence two extra tweaks are needed. yum install flex bison zlib-devel tcl-devel tk-devel gcc-c++ gettext \ libtiff-devel libpng-devel sqlite-devel \ mesa-libGL-devel mesa-libGLU-devel mesa-libGLw-devel \ mesa-libOSMesa-devel libXmu-devel python-devel gtk2-devel\ ncurses-devel postgresql-devel make
Preparation Centos 6 | Scientific Linux 6:
yum install epel-release yum install flex bison make zlib-devel gcc-c++ gettext \ sqlite-devel mesa-libGL-devel mesa-libGLU-devel \ libXmu-devel libX11-devel fftw-devel libtiff-devel \ lesstif-devel python-devel numpy wxPython wxGTK-devel \ proj proj-devel proj-epsg proj-nad libxml2 gdal gdal-devel geos geos-devel \ python-dateutil python-imaging python-matplotlib python-argparse # only GRASS GIS 6: install also tcl-devel tk-devel
Preparation Centos 7 | Scientific Linux 7:
yum install epel-release yum install flex bison make zlib-devel gcc-c++ gettext \ sqlite-devel mesa-libGL-devel mesa-libGLU-devel \ libXmu-devel libX11-devel fftw-devel libtiff-devel \ lesstif-devel python-devel numpy wxPython wxGTK-devel \ proj proj-devel proj-epsg proj-nad libxml2 gdal gdal-devel geos geos-devel \ netcdf netcdf-devel blas-devel lapack-devel atlas-devel \ python-dateutil python-imaging python-matplotlib python-sphinx \ doxygen subversion
GRASS GIS 7 compilation and installation
Download source code (e.g., --> "Download latest 7.0-svn code (SVN))" and configure GRASS 7 (suggestion: save this as script):
./configure \ --with-cxx \ --enable-largefile \ --with-proj --with-proj-share=/usr/share/proj \ --with-gdal=/usr/bin/gdal-config \ --with-sqlite \ --with-python \ --with-cairo --with-cairo-ldflags=-lfontconfig \ --with-freetype --with-freetype-includes=/usr/include/freetype2 \ --with-wxwidgets=/usr/bin/wx-config \ --with-openmp \ --with-blas --with-blas-includes=/usr/include/atlas-x86_64-base/ \ --with-lapack --with-lapack-includes=/usr/include/atlas-x86_64-base/ \ --with-fftw \ --with-geos \ --with-netcdf \ --without-ffmpeg \ --without-mysql \ --without-postgres \ --without-odbc \ --without-fftw
Compile:
make
or on a multicore system (number depends of available cores):
make -j4
For a system wide installation, run as root user:
make install
OR simply run it directly from the source code directory (substitute ARCH with i686 or x86_64):
bin.$ARCH/grass70 -gui
In this case, for convenience, add it to the search path:
mkdir $HOME/bin cd $HOME/bin # example: ln -s $HOME/software/grass70_release/bin.i686-pc-linux-gnu/grass70 .
Now use it subsequently with
grass70 -gui
Gentoo
./configure \ --with-freetype=yes --with-freetype-includes="/usr/include/freetype2/"
See also http://packages.gentoo.org/package/sci-geosciences/grass
Funtoo
Fedora
GRASS GIS 6 on Fedora
Preparation for the compilation of GRASS GIS 6 source code (F16-F21):
yum install proj-devel gdal-devel sqlite-devel ffmpeg-devel mesa-libGL-devel \ mesa-libGLU-devel libXmu-devel libX11-devel tcl-devel tk-devel geos \ fftw-devel libtiff-devel lesstif-devel python-devel numpy wxPython wxGTK-devel \ gcc gcc-c++ bison flex ncurses-devel proj-epsg proj-nad xml2 subversion
Note 1: that currently gdal-devel has (too) many dependencies and may lead to a massive download of extra packages (200 on a fresh Fedora 16 install). Hopefully solved in later Fedora versions.
Note 2: the optional ffmpeg-devel comes from the rpmfusion-free repository (configuration).
Download the source code:
- GRASS GIS 6: release package - weekly snapshot - SVN repository
Configure: This is an example how to configure the source code on a Fedora system:
./configure \ --with-cxx \ --with-gdal=/usr/bin/gdal-config \ --with-proj --with-proj-share=/usr/share/proj \ --with-sqlite \ --with-nls \ --with-geos \ --with-wxwidgets=/usr/bin/wx-config \ --with-python=/usr/bin/python-config \ --with-freetype --with-freetype-includes=/usr/include/freetype2 \ --enable-largefile \ --without-odbc \ --with-fftw
Extra: If you also want FFMPEG support - it requires 'yum install fftw-devel'. Then add to the configuration lines above:
--with-ffmpeg --with-ffmpeg-includes="/usr/include/ffmpeg /usr/include/ffmpeg/libav* /usr/include/ffmpeg/libpostproc /usr/include/ffmpeg/libswscale" \
Finally compile the configured source code:
make or on multicore (number depends of available cores): make -j4 and make install # requires root permissions unless you become owner of /usr/local/
Then use GRASS GIS 6 and enjoy!
GRASS GIS 7 on Fedora
Preparation for the compilation of GRASS GIS 7 source code (F20-F22):
dnf install gcc gcc-c++ bison flex ncurses-devel proj-epsg proj-nad xml2 \ proj-devel gdal gdal-devel gdal-python sqlite-devel mesa-libGL-devel \ fftw-devel mesa-libGLU-devel libXmu-devel libX11-devel geos geos-devel \ libtiff-devel python-devel numpy wxPython wxGTK-devel \ python-dateutil python-imaging python-matplotlib-wx subversion doxygen python-sphinx
# optionally also: netcdf-devel postgresql-devel lesstif-devel
Note 1: the optional ffmpeg-devel comes from the rpmfusion-free repository (configuration).
Download the source code:
- GRASS GIS 7: weekly snapshot - SVN repository
Configure: This is an example how to configure the source code on a Fedora system:
./configure \ --with-cxx \ --with-gdal=/usr/bin/gdal-config \ --with-proj --with-proj-share=/usr/share/proj \ --with-python=/usr/bin/python-config \ --with-geos \ --with-sqlite \ --with-nls \ --with-wxwidgets=/usr/bin/wx-config \ --with-fftw \ --with-cairo --with-cairo-ldflags=-lfontconfig \ --with-freetype --with-freetype-includes=/usr/include/freetype2 \ --enable-largefile \ --without-odbc
Extra 1: If you also want FFMPEG support - it requires 'dnf install fftw-devel' from the rpmfusion-free repository. Then add to the configuration lines above:
--with-ffmpeg --with-ffmpeg-includes="/usr/include/ffmpeg /usr/include/ffmpeg/libav* /usr/include/ffmpeg/libpostproc /usr/include/ffmpeg/libswscale" \
Extra 2: For LAPACK/BLAS support (addons i.spec.unmix, v.kriging etc), install "dnf install lapack lapack-devel blas blas-devel atlas atlas-devel". Then add to the configuration lines above:
--with-blas --with-blas-includes=/usr/include/atlas-x86_64-base/ \ --with-lapack --with-lapack-includes=/usr/include/atlas-x86_64-base/ \
Finally compile the configured source code:
make or on multicore (number depends of available cores): make -j4 and make install # requires root permissions unless you become owner of /usr/local/
Then use GRASS GIS 7 and enjoy!
openSUSE
To build GRASS on openSUSE:
RPM packages to be installed:
sudo zypper install bison flex freetype2-devel fftw3-devel gcc-c++ \
libgdal-devel libgeos-devel libjpeg-devel libpng-devel libtiff-devel \
man proj libproj-devel readline-devel netcdf-devel ncurses-devel \
mysql-devel postgresql-devel sqlite-devel unixODBC-devel \
tcl-devel tk-devel xorg-x11-Mesa-devel libXmu-devel \
python-numpy python-dateutil python-devel python-opengl \
python-wxWidgets python-xml python-dateutil wxWidgets-devel \
zlib-devel doxygen python-sphinx
Source code configuration:
./configure \
--enable-largefile \
--with-proj-share=/usr/share/proj \
--with-cxx \
--with-lapack=yes \
--with-x \
--with-motif \
--with-gdal=/usr/bin/gdal-config \
--with-postgres --with-postgres-includes=/usr/include/pgsql \
--with-mysql --with-mysql-includes=/usr/include/mysql \
--with-fftw \
--with-readline \
--with-netcdf \
--with-curses \
--with-geos \
--with-nls \
--with-sqlite \
--with-freetype \
--with-freetype-includes=/usr/include/freetype2 \
--with-wxwidgets \
--with-odbc \
--with-python
Then compile with "make [-j2]".
Arch Linux
Up-to-date links to Arch Linux GRASS PKGBUILDs are on https://grass.osgeo.org/download/software/linux/.
But if you want to compile it yourself, you have to keep in mind that in Arch Linux the default Python version 3.
python --version
Python 3.3.1
Therefore, to build GRASS GIS (version 7 in this example), we can use either use virtualenv or symlink python2 and python2-config in a given directory. Let's use the latter approach
sudo ln -s /usr/bin/python2 $HOME/usr/bin/python sudo ln -s /usr/bin/python2-config $HOME/usr/bin/python-config
We can now start building GRASS 7
export PATH=~/usr/bin:$PATH && \ ./configure \ --enable-debug \ --enable-64bit \ --with-libs=/usr/lib64 \ --with-cxx \ --with-readline \ --with-zlib-includes="/usr/include/" \ --with-freetype=yes \ --with-freetype-includes="/usr/include/freetype2/" \ --enable-largefile=yes \ --with-gdal=/usr/bin/gdal-config \ --with-proj-share=/usr/share/proj/ \ --with-geos=/usr/bin/geos-config \ --with-cairo \ --with-odbc \ --with-pthread \ --with-liblas=/usr/local/bin/liblas-config \ --with-fftw-includes="/usr/include/" \ --with-fftw-libs=/usr/lib/ \ --with-tcltk-includes="/usr/include/" \ --with-wxwidgets \ --with-postgres=yes \ --with-postgres-includes="/usr/include/postgresql/internal" \ --with-postgres-libs="/usr/include/postgresql/internal/libpq" \ --with-sqlite=yes \ --with-python=yes \ --with-liblas \ --with-netcdf
Now let's compile and install it
make sudo make install
Now the final step required to use GRASS with python2 is to create a bash script "grass" (or the name you want)
#!/bin/bash export PATH=~/usr/bin:$PATH python2 /usr/local/bin/grass70
And make it executable and copy it somewhere in the PATH
chmod+x grass sudo cp grass /usr/local/bin
It's done, you can enjoy GRASS 7 in Arch, just type "grass" (or the name you gave to the script) in the terminal to launch it.
RPM SPEC files
Zaurus
... see here for instructions
Mac OSX
Conventional installation
- see the source/macosx readme (Trac link)
- main page Compiling on MacOSX
- main page Packaging on MacOSX
- official download site
- build scripts for dependencies
- solving errors at starting GRASS GIS: MacOSX GRASS errors
Compiling on MacOSX using homebrew
Compiling on MacOSX using Fink
FreeBSD / NetBSD
The recommended compiler tools are GCC, GNU make, GNU coreutils (for install), and flex. All are available through the respective package managing tools (pkg_add for FreeBSD and pkgin install for NetBSD) and for recent *BSD versions most likely installed by default.
GRASS 6.x and GRASS 7 should compile on FreeBSD 8.0 or later and NetBSD 5.0 or later (maybe also on updated NetBSD 4.x).
It is highly recommended to install GDAL/OGR and PROJ4 first. These libraries and tools are available as ports for FreeBSD and packages for NetBSD.
Optional functionality is listed with ./configure --help, and related libraries and tools might need to be installed first.
You then may need to edit include/Make/Platform.make and set
ICONVLIB = -liconv
Solaris
- 2008 Oct 15: see this post on the grass mailing list
11 SPARC/i86pc
The recommended compiler tools are GCC, GNU make, GNU coreutils (for install), and flex. All are available through the Solaris package manager.
Most dependencies are available through the Solaris package manager. GDAL and proj4 can either be compiled from source or installed e.g. from OpenCSW. If packages are installed from OpenCSW, the linker flags need to be set with
LDFLAGS="-Wl,-R/opt/csw/lib -L/opt/csw/lib -Wl,-R/opt/csw/gxx/lib -L/opt/csw/gxx/lib"
See also the OpenCSW documentation.
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
A recent GNU make (>= 3.81) and GNU coreutils are required. These are available with the IBM AIX toolbox or through third-party AIX software repositories, e.g. bullfreeware and perzl.org. Note that 'make' does not work, only 'gmake' works.
General instructions to compile on AIX are e.g. here
On AIX, compilation results by default in 32 bit applications and static libraries. The IBM documentation explains how to build 64 bit applications and shared libraries with GCC.
GRASS 6: Using the IBM xlc compiler:
Mike wrote in 2009:
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:
# xlc compiler: 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
GRASS 7: Using the IBM xlc compiler:
Get and install (in this order):
- GNU tar
- GNU make (>= 3.81)
- SQLite
- PROJ.4 (for ./configure parameters, see here)
- GDAL (for ./configure parameters, see here)
- GRASS GIS 7
The environment variables and configure command that worked:
## AIX 5.x export LIBPATH=/opt/freeware/lib64:/opt/freeware/lib # make 'ar' happy export OBJECT_MODE=64 PREFIX=$HOME/private/bin ./configure \ --prefix=$PREFIX \ --disable-shared \ --enable-largefile \ --with-cxx \ --with-proj-includes=$PREFIX/include/ \ --with-proj-libs=$PREFIX/lib/ \ --with-proj-share=$PREFIX/share/proj/ \ --with-sqlite \ --with-sqlite-includes=$PREFIX/include/ \ --with-sqlite-libs=$PREFIX/lib/ \ --with-tiff=no \ --with-png=no \ --with-fftw=no \ --with-cairo=no \ --with-freetype=no
GRASS 7: Using the GNU gcc compiler:
Get and install (in this order):
- if needed, GNU tar
- if needed (the name is often 'gmake' and not 'make') GNU make (>= 3.81)
- SQLite
- PROJ.4 (for ./configure parameters, see here)
- GDAL (for ./configure parameters, see here)
- GRASS GIS 7
The environment variables and configure command that worked for AIX 5.x:
## AIX 5.x export LIBPATH=/opt/freeware/lib64:/opt/freeware/lib # make 'ar' happy export OBJECT_MODE=64 PREFIX=$HOME/private/bin CFLAGS='-ansi -D_ALL_SOURCE=1 -D_POSIX_SOURCE=1 -D_POSIX_C_SOURCE=200809L -Dinline=' ./configure \ --prefix=$PREFIX \ --disable-shared \ --enable-largefile \ --with-cxx \ --with-proj-includes=$PREFIX/include/ \ --with-proj-libs=$PREFIX/lib/ \ --with-proj-share=$PREFIX/share/proj/ \ --with-sqlite \ --with-sqlite-includes=$PREFIX/include/ \ --with-sqlite-libs=$PREFIX/lib/ \ --with-tiff=no \ --with-png=no \ --with-fftw=no \ --with-cairo=no \ --with-freetype=no
The environment variables and configure command that worked for AIX 7.x:
## AIX 7.x export CC="gcc" export CXX="g++" PREFIX=$HOME/bin LDFLAGS="-Wl,-bsvr4,-R,/opt/freeware/lib -L/opt/freeware/lib" CPPFLAGS="-I/opt/freeware/include" ./configure \ --prefix=$PREFIX \ --enable-largefile \ --enable-shared \ --with-includes=/opt/freeware/include --with-libs=/opt/freeware/lib \ --with-cxx \ --with-proj-includes=$PREFIX/include/ \ --with-proj-libs=$PREFIX/lib/ \ --with-proj-share=$PREFIX/share/proj/ \ --with-gdal=$PREFIX/bin/gdal-config \ --with-sqlite \ --with-sqlite-libs=$PREFIX/lib --with-sqlite-includes=$PREFIX/include \ --with-png=no \ --with-tiff=no \ --with-fftw=no \ --with-cairo=no \ --with-opengl=no \ --with-freetype=no
MS-Windows
MS-Windows/Cygwin
- See the Cygwin wiki pages
MS-Windows/native
Compile
- GRASS Windows Native Binary Building Guide (GRASS 6.4.x + 7.x)
GRASS Windows Native Binary Building Guide (GRASS 6.3.x)- See/adapt idea for unattended install of QGIS (et al) from OSGeo4W from the QuantumGIS Blog.
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
- error: g.list: error while loading shared libraries: libgdal1.6.0.so.1: cannot open shared object file: No such file or directory
- this error appears in the shell right after the user clicks GUI's "Start GRASS" button. The GUI shows an error about geographic extent and gets closed afterwards.
- It happens when you launch bin.i686 executable on 64bit system. Be careful and choose the right architecture.
Static compilation
In order to get static rather than dynamically linked binaries, configure like this:
./configure --disable-shared --enable-static
This will however break the wxGUI and GRASS 7 completely because "ctypes" wants to link against shared libs, or there is something in the static libs that "ctypes" does not like.
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
GRASS-GDAL plugin
Addons
Please note that the installation of Addons can be easily done with the g.extension manager. The compile instructions below are aiming at own development.
Compiled modules
This is the general way which works for C modules as well as scripts (Python or Shell/Bash modules) which has HTML documentation.
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/
Note that the /path/to/grass64 has to be absolute, not relative.
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