Difference between revisions of "Compile and Install"

From GRASS-Wiki
Jump to: navigation, search
m (Reverted edits by Reverse22 (talk) to last revision by Neteler)
(update URL)
 
(172 intermediate revisions by 27 users not shown)
Line 1: Line 1:
{{MoveToTrac}}
+
<!-- {{MoveToTrac}} -->
  
'''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 [http://grass.osgeo.org/download/ here], otherwise read on...
+
'''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 [https://grass.osgeo.org/download/ here], otherwise read on...
  
== How to do compilation and installation of GRASS 6? ==
+
== 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.
+
Here we explain the procedure to compile GRASS from GitHub, but it also applies to official GRASS 7 releases.
  
 
''For installation of precompiled binary packages, see the main [[Installation Guide]].''
 
''For installation of precompiled binary packages, see the main [[Installation Guide]].''
  
For detailed information on compilation, please see the [http://grass.osgeo.org/grass64/source/INSTALL INSTALL] file in the source code.
+
For detailed information on compilation, please see the [https://github.com/OSGeo/grass/blob/master/INSTALL INSTALL] file in the source code.
  
 
=== Prerequisites ===
 
=== Prerequisites ===
  
GRASS needs at least two extra libraries: PROJ and GDAL/OGR
+
==== Extra libraries ====
 +
GRASS GIS needs at least two extra libraries: PROJ and GDAL/OGR. It is recommended to download them as ready-to-use packages for your software platform (Linux distribution, Windows, Mac...).
  
''Note: if you want to have DBMS support in GDAL (subsequently in GRASS) you have to perform the "Optional" steps below as well.''
+
Other libraries needed to run GRASS are listed on the [http://htmlpreview.github.io/?https://github.com/OSGeo/grass/blob/master/REQUIREMENTS.html requirements page].
  
* [http://trac.osgeo.org/proj/ PROJ4] for management of projections (with proj-datumgrid-1.3.zip support)
+
To compile, you will also need the respective "-devel" packages; see below for details.
* Optional: [http://trac.osgeo.org/geos/ GEOS]
 
* Optional: [http://www.postgresql.org PostgreSQL], [http://www.mysql.org mySQL], [http://www.unixodbc.org unixODBC], [http://www.sqlite.org SQLite] (SQLite is needed for [[QGIS]])
 
* [http://www.gdal.org GDAL/OGR] for reading and writing various GIS data formats (interoperability)
 
  
You have to install these two libraries '''first'''.
+
==== Download GRASS GIS source code ====
  
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.
+
First, [https://grass.osgeo.org/download/ download the GRASS GIS source code].
 
 
 
 
Other libraries needed to run GRASS are listed on the {{website|grass64/source/REQUIREMENTS.html|requirements page}}.
 
 
 
To compile, you will also need the respective "-devel" packages.
 
 
 
Then [http://grass.osgeo.org/download/index.php#g64x download GRASS] of course.
 
  
 
=== Generic Compilation and installation procedure ===
 
=== 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:
+
* 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/  
 
       cd /usr/local/src/  
       su -c 'mkdir grass6'
+
       su -c 'mkdir grass7'
       su -c 'chown yourlogin:yourgroup grass6'
+
       su -c 'chown yourlogin:yourgroup grass7'
  
 
Otherwise if you have permissions just continue as a normal user:
 
Otherwise if you have permissions just continue as a normal user:
       cd /usr/local/src/
+
      mkdir $HOME/src
       svn checkout ...
+
       cd $HOME/src/
 
+
       git clone https://github.com/OSGeo/grass.git grass_master
* do a code checkout from the SVN source code repository
 
: checkout the latest GRASS 6.x from SVN (see: {{twiki|DownloadSource}})
 
 
 
* 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:
 
* run configure with parameters to adapt the compile process to your own system. To see what options can be passed to it, run:
Line 60: Line 47:
 
           --with-cxx \
 
           --with-cxx \
 
           --with-sqlite \
 
           --with-sqlite \
           --with-postgres-libs=/usr/include/pgsql/libpq \
+
           --with-python \
           --with-postgres-includes=/usr/include/pgsql \
+
          --with-geos \
 +
          --with-gdal=/usr/bin/gdal-config \
 +
           --with-cairo --with-cairo-ldflags=-lfontconfig \
 
           --with-freetype \
 
           --with-freetype \
 
           --with-freetype-includes=/usr/include/freetype2 \
 
           --with-freetype-includes=/usr/include/freetype2 \
           --with-motif \
+
           --with-proj --with-proj-share=/usr/share/proj
          --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).
 
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).
Line 79: Line 67:
 
At the end of configuration process you should get report not much different from this:
 
At the end of configuration process you should get report not much different from this:
  
GRASS is now configured for:  i686-pc-linux-gnu
+
  GRASS is now configured for:  x86_64-pc-linux-gnu
+
 
Source directory:           /usr/src/grass6
+
  Source directory:           /home/user/software/grass_master
Build directory:             /usr/src/grass6
+
  Build directory:           /home/user/software/grass_master
Installation directory:     /usr/local/grass-6.3.svn
+
  Installation directory:     ${prefix}/grass79
Startup script in directory: ${exec_prefix}/bin
+
  Startup script in directory:${exec_prefix}/bin
C compiler:                 gcc -g -O2
+
  C compiler:                 gcc -O2 -march=native -std=gnu99 -fexceptions -fstack-protector -m64 -fdiagnostics-color
C++ compiler:               c++ -g -O2
+
  C++ compiler:               c++ -g -Wall
  FORTRAN compiler:             
+
  Building shared libraries: yes
Building shared libraries:   yes
+
  OpenGL platform:            X11
64bit support:               no
+
    
+
  MacOSX application:         no
   NVIZ:                       yes
+
  MacOSX architectures:     
+
   MacOSX SDK:                
   BLAS support:              no
+
 
 +
   BLAS support:              yes
 +
  BZIP2 support:              no
 
   C++ support:                yes
 
   C++ support:                yes
 +
  Cairo support:              yes
 
   DWG support:                no
 
   DWG support:                no
  FFMPEG support:            no
 
 
   FFTW support:              yes
 
   FFTW support:              yes
 
   FreeType support:          yes
 
   FreeType support:          yes
 
   GDAL support:              yes
 
   GDAL support:              yes
   GLw support:                no
+
   GEOS support:              yes
  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...)!
 
* Let's compile it (takes a little while...)!
       make
+
       make -j2
 
* At the end, you should get report not much different from this:
 
* At the end, you should get report not much different from this:
 
  ----------------------------------------------------------------------
 
  ----------------------------------------------------------------------
Line 126: Line 101:
 
  GRASS GIS compilation log
 
  GRASS GIS compilation log
 
  -------------------------
 
  -------------------------
  Started compilation: Ne kvě 28 13:18:43 CEST 2006
+
  Started compilation: Mon 19 Aug 2019 10:47:57 PM CEST
 
  --
 
  --
 
  Errors in:
 
  Errors in:
 +
No errors detected.
 
  --
 
  --
  Finished compilation: Ne kvě 28 13:43:40 CEST 2006
+
  Finished compilation: Mon 19 Aug 2019 10:55:12 PM CEST
 
  (In case of errors please change into the directory with error and run 'make')
 
  (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
+
* If there is any error, change directory to directory with error and run "make" again. Report occurring bug to GRASS mailing list
 
* Once the installation process is finished, you're ready to install GRASS system wide.
 
* Once the installation process is finished, you're ready to install GRASS system wide.
 
       su -c 'make install'
 
       su -c 'make install'
 
* enjoy GRASS:  
 
* enjoy GRASS:  
       grass64
+
       grass79
  
 
=== What else? ===
 
=== What else? ===
Line 153: Line 129:
 
==== Linux ====
 
==== Linux ====
  
===== Debian =====
+
Linux comes in various flavours, i.e. distributions.
 +
 
 +
===== Distribution related packaging =====
 +
 
 +
* Arch Linux: https://github.com/czka/AUR-grass7
 +
* Centos: https://src.fedoraproject.org/rpms/grass
 +
* Debian: https://trac.osgeo.org/grass/wiki/DebianUbuntuPackaging
 +
* EPEL: https://src.fedoraproject.org/rpms/grass
 +
* Fedora: https://src.fedoraproject.org/rpms/grass
 +
* Ubuntu: https://trac.osgeo.org/grass/wiki/DebianUbuntuPackaging
 +
 
 +
===== Generic procedure for Debian-based distributions (Ubuntu, ...) =====
 +
 
 +
WORK IN PROGRESS
 +
 
 +
1. Install official GRASS package
 +
 
 +
sudo apt install grass grass-dev
 +
 
 +
2. Enable source code download
 +
 
 +
# do backup first
 +
sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig
 +
sudo sed -i '/^#\sdeb-src /s/^# *//' /etc/apt/sources.list
 +
 
 +
3. Install GRASS dependencies
 +
 
 +
sudo apt build-dep grass
 +
 
 +
4. Download GRASS source code
 +
 
 +
git clone https://github.com/osgeo/grass
 +
 
 +
5. Compile GRASS from source code
 +
 +
cd grass
 +
 
 +
Configure:
 +
 
 +
grass --config build | sh
 +
 
 +
Optionally install missing dependecies (can happen when official GRASS package is not compatible with GRASS master), eg.
 +
 
 +
sudo apt install libzstd-dev
 +
 
 +
Compile:
  
Read the instructions here:
+
make -j2
: http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/debian/README.debian
 
  
  # first install PROJ, GDAL, etc.
+
6. Run locally or install
  cd grass64/
 
  # follow instructions in debian/README.debian
 
  fakeroot buildpackage
 
  
* Official [http://wiki.debian.org/DebianGis DebianGIS] packaging [http://svn.debian.org/viewsvn/pkg-grass/packages/grass/ control files], also accessible via svn:
+
./bin.x86_64-pc-linux-gnu/grass79 --version
  
  svn co svn://svn.debian.org/svn/pkg-grass/packages/grass/trunk/
+
or
  
or
+
sudo make install
 +
grass79 --version
  
   svn co svn://svn.debian.org/svn/pkg-grass/packages/grass/branches/<GRASS Version>
+
===== Debian =====
 +
 
 +
* Official [http://wiki.debian.org/DebianGis DebianGIS] packaging control files, 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.1 on Debian Sarge ======
Line 181: Line 204:
 
           tcl-dev tk-dev libfftw3-dev libxmu-dev libfreetype6-dev autoconf2.13 autotools-dev doxygen \
 
           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 \
 
           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
+
           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:
Line 194: Line 219:
 
   --with-tcltk-includes=/usr/include/tcl8.4/ \
 
   --with-tcltk-includes=/usr/include/tcl8.4/ \
 
   --with-freetype --with-freetype-includes=/usr/include/freetype2 \
 
   --with-freetype --with-freetype-includes=/usr/include/freetype2 \
   --with-motif --with-fftw --with-nls --with-python
+
   --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:
 
Compile:
Line 205: Line 270:
  
 
Install needed packages:
 
Install needed packages:
  apt-get install flex bison debhelper dpatch autoconf2.13 autotools-dev python-dev  
+
  apt-get install flex bison debhelper dpatch autoconf2.13 autotools-dev python-dev \
 
     g++ gcc gettext graphviz libcairo2-dev libfftw3-dev libfreetype6-dev \
 
     g++ gcc gettext graphviz libcairo2-dev libfftw3-dev libfreetype6-dev \
     libgdal1-1.6.0 libgdal1-dev libglu1-mesa-dev libglw1-mesa-dev \
+
     libgdal1 libgdal1-dev libglu1-mesa-dev libglw1-mesa-dev \
 
     libncurses5-dev libproj-dev libreadline-dev libsqlite3-dev libtiff4-dev \
 
     libncurses5-dev libproj-dev libreadline-dev libsqlite3-dev libtiff4-dev \
 
     libwxgtk2.8-dev libxmu-dev libxmu-headers libxt-dev mesa-common-dev \
 
     libwxgtk2.8-dev libxmu-dev libxmu-headers libxt-dev mesa-common-dev \
     proj-bin python-numpy python-wxgtk2.8 subversion wx-common zlib1g-dev
+
     proj-bin proj-data python-numpy python-wxgtk2.8 subversion wx-common zlib1g-dev
  
 
Download source code:
 
Download source code:
Line 217: Line 282:
  
 
Configure:
 
Configure:
 
+
  CFLAGS="-g -Wall -Werror-implicit-function-declaration -fno-common -Wextra -Wunused" \
+
cd grass_trunk/
  CXXFLAGS="-g -Wall"  \
+
  CFLAGS="-Wall -Werror-implicit-function-declaration -fno-common -Wextra -Wunused" \
 +
  CXXFLAGS="-Wall"  \
 
   ./configure --prefix=/usr/local \
 
   ./configure --prefix=/usr/local \
 
   --with-gdal --with-proj --with-proj-share=/usr/share \
 
   --with-gdal --with-proj --with-proj-share=/usr/share \
Line 235: Line 301:
  
 
Install:
 
Install:
   sudo make install
+
   sudo make install # installs as /usr/local/bin/grass72
 +
 
 +
====== 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/grass78/source/grass-7.8.0.tar.gz
 +
tar -zxvf grass-7.8.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
  
===== Ubuntu =====
+
Compile:
 +
make -j2
  
''The above Debian notes will probably work with Ubuntu as well.''
+
Install:
 +
sudo make install  # installs as /usr/local/bin/grass70
  
A more [[Compile_and_Install_Ubuntu | specific page]] towards Ubuntu is being written on.
+
Launch:
 +
  grass70
  
====== Ubuntu 6.06, 7.10 ======
+
====== GRASS 7 on Debian Jessie ======
  
* [http://david.p.finlayson.googlepages.com/makegrass.sh makegrass.sh] is script designed to automate most of the download, configuration and compilation of GRASS 6.x-CVS
+
Install needed packages:
** it is advised use [https://help.ubuntu.com/community/CheckInstall checkinstall] (''sudo apt-get install checkinstall'') instead of ''make install'' to keep track of installed software
+
sudo apt-get install cmake libboost-all-dev flex bison debhelper dpatch autoconf2.13 \
** Think twice before using this script. Some users experienced problems such as disabled XGL etc.
+
    autotools-dev python-dev g++ gcc gettext graphviz libcairo2-dev libfftw3-dev \
* [[User:Steko/Automated_CVS_compiling|Here]] is another of these scripts, it's homemade so probably you'll find the above more useful for production sites.
+
    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 liblapack3gf liblapack-dev
 +
    # opencl-headers ocl-icd-libopencl1  liblas-bin liblas-c-dev python-gdal
  
====== Ubuntu 7.10 64-bit ======
+
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
  
* 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
+
Download and compile GRASS 7:
(Based on "Ubuntu 6.06 LTS - GRASS 6.1 Compilation Script" by David Finlayson)
+
# (check there for later version)
''Assuming it is the first time attempting to compile GRASS' source code & installing SVN, PROJ, GDAL/OGR''
+
wget http://grass.osgeo.org/grass74/source/grass-7.4.0.tar.gz
 +
tar xzfv grass-7.4.0.tar.gz
 +
cd grass-7.4.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
  
'''Preparation'''
+
Install:
  sudo apt-get update && sudo apt-get upgrade
+
  sudo make install  # installs as /usr/local/bin/grass74
  
* install dependencies for compiling (in general) and dependencies for GRASS: PROJ, GDAL/OGR
+
====== GRASS 7 on Debian Stretch ======
sudo apt-get install grass build-essential flex bison libncurses5-dev zlib1g-dev \
+
(Updated from above with package changes required for Debian Stretch)
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
+
Install needed packages for GRASS 7.2 - 7.6:
sudo apt-get install sqlite3 libsqlite3-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 python-wxtools wx-common zlib1g-dev netcdf-bin \
 +
    libnetcdf-dev libgegl-dev  doxygen python-sphinx postgresql libgeotiff-dev libblas-dev \
 +
    mariadb-server libatlas-dev liblapack3 liblapack-dev opencl-headers ocl-icd-libopencl1 \
 +
    subversion liblas-bin liblas-c-dev python-gdal libpdal-dev libpdal-plugin-python pdal
  
* install SVN
+
Install needed packages for GRASS 7.8+ (Python 3 support!):
sudo apt-get install subversion
+
  apt-get install cmake libboost-all-dev flex bison debhelper dpatch autoconf2.13 autotools-dev \
 +
    g++ gcc gettext graphviz libcairo2-dev libfftw3-dev libfreetype6-dev libgdal20 python3-dev \
 +
    libgdal-dev libglu1-mesa-dev libglw1-mesa-dev libproj-dev libreadline-dev libgeos-c1v5 \
 +
    libsqlite3-dev libtiff5-dev libwxgtk3.0-dev libxmu-dev libxmu-headers libxt-dev mesa-common-dev \
 +
    proj-bin proj-data python3-numpy python3-six wx-common zlib1g-dev netcdf-bin \
 +
    libnetcdf-dev libgegl-dev  doxygen python3-sphinx postgresql libgeotiff-dev libblas-dev \
 +
    libatlas-dev liblapack3 liblapack-dev opencl-headers ocl-icd-libopencl1 \
 +
    subversion liblas-bin liblas-c-dev python3-gdal libpdal-dev libpdal-plugin-python pdal
 +
   
 +
    # ? python3-wxgtk4.0 libmariadb
  
* 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''')
+
Download and unpack source code or fetch from GitHub: https://github.com/OSGeo/grass
  
sudo mkdir /usr/local/src
+
Configuration:
  
* grant rwx (read-write-execute) permissions for our userid/ groupid on the directory (replace words userid and groupid with real userid):
+
  CFLAGS="-Wall -Werror-implicit-function-declaration -fno-common -Wextra -Wunused" \
sudo chown ''userid'':''groupid'' /usr/local/src
+
  CXXFLAGS="-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
  
sudo chmod ug+rwx /usr/local/src
+
Compile:
  
* download latest source code from GRASS SVN repository in a directory on the system (e.g. /usr/local/src)
+
  make -j2
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
+
Install:
  
----
+
  make install
'''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
+
====== GRASS 7 on Debian Buster ======
sudo apt-get install fftw3 fftw3-dev
 
  
'''FFMPEG'''
+
-- To be updated --
  
Note: Back in Ubuntu 7.10, installing ffmpeg through the repositories wouldn't work with grass. The following steps were successfully used.
+
Install needed packages for GRASS 7.8+ (Python 3 support!):
 +
  apt-get install cmake libboost-all-dev flex bison debhelper dpatch autoconf2.13 autotools-dev \
 +
    g++ gcc gettext graphviz libcairo2-dev libfftw3-dev libfreetype6-dev libgdal20 python3-dev \
 +
    libgdal-dev libglu1-mesa-dev libglw1-mesa-dev libproj-dev libreadline-dev libgeos-c1v5 \
 +
    libsqlite3-dev libtiff5-dev libwxgtk3.0-dev libxmu-dev libxmu-headers libxt-dev mesa-common-dev \
 +
    proj-bin proj-data python3-numpy python3-six wx-common zlib1g-dev netcdf-bin \
 +
    libnetcdf-dev libgegl-dev  doxygen python3-sphinx postgresql libgeotiff-dev libblas-dev \
 +
    liblapack3 liblapack-dev opencl-headers ocl-icd-libopencl1 \
 +
    subversion liblas-bin liblas-c-dev python3-gdal libpdal-dev libpdal-plugin-python pdal \
 +
    python3-wxgtk4.0 default-libmysqlclient-dev
  
* install FFMPEG (information taken from: http://stream0.org/2008/01/install-ffmpeg-on-ubuntu-gutsy.html)
+
Download and unpack source code or fetch from GitHub: https://github.com/OSGeo/grass
* download source code with svn
 
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
 
  
* install dependencies
+
Configuration:
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
+
  CFLAGS="-Wall -Werror-implicit-function-declaration -fno-common -Wextra -Wunused" \
  cd ffmpeg
+
  CXXFLAGS="-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
  
if necessary: '''make distclean''' before configuration (look at notes below)
+
Compile:
  
* configuration ('''note:''' the configuration parameter "'''--enable-pp'''" does not work anymore)
+
  make -j2
# 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
+
Install:
make
 
  
* installation on /usr/local/bin -- important to remember when configuring GRASS' source code for compilation
+
  make install
sudo checkinstall
 
  
'''Go for GRASS!'''
+
===== Ubuntu =====
* in our example we used the /usr/local/src directory to store GRASS' source code, so:
 
cd /usr/local/src/grass_trunk
 
  
* configuration
+
There is a dedicated page on how to [[Compile_and_Install_Ubuntu | Compile the GRASS GIS source code & install it in Ubuntu]].
  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
+
===== Linux Mint =====
  
cd /usr/include/GL
+
The [[Compile_and_Install_Ubuntu | detailed compilation guide for Ubuntu]] may just work. However, here is a short guide for Mint:
  
sudo ln glxATI.h glx.h
+
<source lang="bash">
 +
# Linux Mint 20
  
* compilation
+
# be sure to have an updated system
make
+
sudo apt-get update && sudo apt-get upgrade -y
  
* compilation is expected to end with a statement similar to the following:
+
# installation of required libraries and compile tools
 +
# recommended to give Python3 precedence over Python2 (which is end-of-life since 2019)
 +
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
  
Started compilation: Wed Feb 27 00:24:36 CET 2008
+
# install compiler tools and further dependencies (tested with Linux Mint 20)
--
+
# this is a single command, please copy-paste it entirely into the terminal:
Errors in:
+
sudo apt-get install \
No errors detected.
+
  build-essential \
 +
  flex make bison gcc libgcc1 g++ cmake ccache \
 +
  libproj-dev proj-data proj-bin \
 +
  libgeos-dev \
 +
  libgdal-dev python3-gdal gdal-bin \
 +
  python3 python3-dev \
 +
  python3-opengl \
 +
  python-wxversion python-wxtools python-wxgtk3.0 python3-wxgtk4.0 \
 +
  python3-dateutil libgsl-dev python3-numpy \
 +
  wx3.0-headers wx-common libwxgtk3.0-gtk3-dev libwxbase3.0-dev \
 +
  libncurses5-dev zlib1g-dev gettext \
 +
  libbz2-dev libzstd-dev libfreetype6-dev \
 +
  libtiff5-dev libpnglite-dev libcairo2 libcairo2-dev \
 +
  sqlite3 libsqlite3-dev libpq-dev \
 +
  libfftw3-3 libfftw3-dev \
 +
  libboost-thread-dev libboost-program-options-dev \
 +
  subversion \
 +
  checkinstall \
 +
  libglu1-mesa-dev libxmu-dev \
 +
  ghostscript wget -y
 +
</source>
  
* installation
+
Next steps:
sudo checkinstall
+
* download [https://grass.osgeo.org/grass-stable/source/snapshot/ GRASS GIS source code] (e.g. take the "7.x-git snapshot")
 +
* unpack source code
 +
* change into the source code directory
  
* launch 64-bit GRASS.6.4.svn
+
<source lang="bash">
grass64
+
# in the source code directory, "configure" the source code to prepare for compilation:
 +
./configure \
 +
  --with-cxx \
 +
  --enable-largefile \
 +
  --with-proj --with-proj-share=/usr/share/proj \
 +
  --with-gdal=/usr/bin/gdal-config \
 +
  --with-python \
 +
  --with-geos \
 +
  --with-sqlite \
 +
  --with-nls \
 +
  --with-zstd \
 +
  --with-cairo --with-cairo-ldflags=-lfontconfig \
 +
  --with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
 +
  --with-wx=/usr/bin/wx-config \
 +
  --with-wxwidgets \
 +
  --with-fftw \
 +
  --with-opengl-libs=/usr/include/GL \
 +
  --without-postgres \
 +
  --without-pdal \
 +
  --without-motif \
 +
  --without-netcdf \
 +
  --without-mysql \
 +
  --without-odbc \
 +
  --without-openmp \
 +
  --without-ffmpeg
  
'''Notes'''
+
# compile GRASS GIS
* in case of errors in future compilation attempts, remember to remove program binaries with
+
make -j2
make clean
 
* and the files created with the "configuration" from previous compilations with
 
make distclean
 
  
====== Ubuntu 8.04 and above ======
+
# install compiled GRASS GIS on system
 +
sudo make install
  
* See [[Compile and Install Ubuntu‎]]
+
# use GRASS GIS! Start on command line
 +
grass78
 +
</source>
  
 
===== Mandriva =====
 
===== Mandriva =====
Line 378: Line 649:
 
   # as root
 
   # as root
 
     urpmi flex bison zlib-devel tiff-devel png-devel tcl-devel tk-devel sqlite3-devel \
 
     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 \
+
           mesagl1-devel mesaglu1-devel lib64xmu6-devel gcc-c++ gettext \
 
           lib64wxgtk2.8 lib64wxgtk2.8-devel lib64wxgtkgl2.8 wxgtk2.8 \
 
           lib64wxgtk2.8 lib64wxgtk2.8-devel lib64wxgtkgl2.8 wxgtk2.8 \
 
           lib64wxPythonGTK2.8 lib64wxPythonGTK2.8-devel wxPythonGTK wxPythonGTK-wxversion
 
           lib64wxPythonGTK2.8 lib64wxPythonGTK2.8-devel wxPythonGTK wxPythonGTK-wxversion
Line 391: Line 662:
 
     # installation of compilation environment
 
     # installation of compilation environment
 
     urpmi flex bison zlib-devel tiff-devel png-devel tcl-devel tk-devel sqlite3-devel \
 
     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 \
+
           lib64mesagl1-devel lib64mesaglu1-devel lib64xmu6-devel gcc-c++ gettext \
           lib64jpeg-devel lib64wxgtk2.8 lib64wxgtk2.8-devel lib64wxgtkgl2.8 wxgtk2.8 \
+
           lib64wxgtk2.8 lib64wxgtk2.8-devel lib64wxgtkgl2.8 wxgtk2.8 \
 
           lib64wxPythonGTK2.8 lib64wxPythonGTK2.8-devel wxPythonGTK wxPythonGTK-wxversion
 
           lib64wxPythonGTK2.8 lib64wxPythonGTK2.8-devel wxPythonGTK wxPythonGTK-wxversion
 
     exit
 
     exit
Line 422: Line 693:
 
     exit
 
     exit
  
===== CentOS =====
+
===== 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
  
Note: CentOS 5 comes with Python 2.4 which lacks python-config, hence two extra tweaks are needed.
+
===== Scientific Linux =====
  
Preparation:
+
See Centos
  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
 
  
 +
===== CentOS =====
  
Compile and install [http://proj.osgeo.org PROJ4]:
+
You first need to add the EPEL repository for PROJ.4 and GDAL, see [https://fedoraproject.org/wiki/EPEL/FAQ#How_can_I_install_the_packages_from_the_EPEL_software_repository.3F here]
  
# get source code and unpack:
+
<strike>
wget http://download.osgeo.org/proj/proj-4.7.0.tar.gz
+
Preparation '''Centos 5''' (old):
tar xvfz proj-4.7.0.tar.gz
+
  yum install epel-release
rm -f proj-4.7.0.tar.gz
 
cd proj-4.7.0/
 
 
   
 
   
# get and install datum files into right directory:
+
  # Note: CentOS 5 comes with Python 2.4 which lacks python-config, hence two extra tweaks are needed.
cd nad/
+
  yum install flex bison zlib-devel tcl-devel tk-devel gcc-c++ gettext \
wget http://download.osgeo.org/proj/proj-datumgrid-1.5.zip
+
              libtiff-devel libpng-devel sqlite-devel \
unzip proj-datumgrid-1.5.zip
+
              mesa-libGL-devel mesa-libGLU-devel mesa-libGLw-devel \
rm -f proj-datumgrid-1.5.zip
+
              mesa-libOSMesa-devel libXmu-devel python-devel gtk2-devel\
cd ..
+
              ncurses-devel postgresql-devel make
 +
</strike>
 +
 
 +
Preparation '''Centos 6''' | '''Scientific Linux 6''':
 +
  yum install epel-release
 
   
 
   
# configure and compile
+
  yum install flex bison make zlib-devel gcc-c++ gettext \
sh configure
+
              sqlite-devel mesa-libGL-devel mesa-libGLU-devel \
make -j4
+
              libXmu-devel libX11-devel fftw-devel libtiff-devel \
+
              lesstif-devel python-devel numpy wxPython wxGTK-devel \
# install (may require "root" permissions, use "su"):
+
              proj proj-devel proj-epsg proj-nad libxml2 gdal gdal-devel geos geos-devel \
make install
+
              python-dateutil python-imaging python-matplotlib python-argparse
 +
  # only GRASS GIS 6: install also tcl-devel tk-devel
  
Compile and install [http://www.gdal.org GDAL]:
+
Preparation '''Centos 7''' | '''Scientific Linux 7''':
# get source code and unpack:
+
  yum install epel-release
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
+
  yum install flex bison make zlib-devel gcc-c++ gettext \
sh configure
+
              sqlite-devel mesa-libGL-devel mesa-libGLU-devel \
make -j4
+
              libXmu-devel libX11-devel fftw-devel libtiff-devel \
+
              lesstif-devel python-devel numpy wxPython wxGTK-devel \
# install (may require "root" permissions, use "su"):
+
              proj proj-devel proj-epsg proj-nad libxml2 gdal gdal-devel geos geos-devel \
make install
+
              netcdf netcdf-devel blas-devel lapack-devel atlas-devel \
+
              python-dateutil python-imaging python-matplotlib python-sphinx \
# add /usr/local/lib/ to LD_LIBRARY_PATH, requires "root" permissions:
+
              doxygen subversion
su -  
 
echo "/usr/local/lib" > /etc/ld.so.conf.d/gdal.conf
 
ldconfig
 
exit
 
 
# test installation by running
 
gdalinfo
 
  
 +
Preparation '''Centos 8''' | '''Scientific Linux 8''':
 +
  dnf install epel-release
  
GRASS 7 compilation and installation, here 64bit example:
+
  dnf install flex bison make zlib-devel gcc-c++ gettext \
 +
              fftw-devel libtiff-devel sqlite-devel \
 +
              proj proj-devel proj-datumgrid libxml2 \
 +
              geos geos-devel git \
 +
              netcdf netcdf-devel atlas-devel \
 +
              blas-devel lapack-devel libpq-devel \
 +
              python3-devel python3-numpy \
 +
              python3-dateutil python3-imaging python3-matplotlib \
 +
              gdal gdal-libs gdal-python-tools python3-gdal gdal-devel \
 +
              wxGTK3-devel mesa-libGL-devel mesa-libGLU-devel \
 +
              libXmu-devel libX11-devel
  
1. Download wxGTP and wxPython:
+
'''GRASS GIS 7 compilation and installation'''
  
  wget http://packages.sw.be/wxPython/wxPython-2.8.9.1-1.el5.rf.x86_64.rpm
+
[https://grass.osgeo.org/grass-stable/source/snapshot/ Download source code] (e.g., --> "Download latest 7.8 code)" and configure GRASS 7 (suggestion: save this as script):
  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. [http://grass.osgeo.org/download/ Download] and configure GRASS 7 (suggestion: save this as script). Note that [http://proj.osgeo.org PROJ4] and [http://www.gdal.org GDAL] must be compiled first:
 
  
 
  ./configure \
 
  ./configure \
  --with-libs=/usr/lib64 \
 
 
   --with-cxx \
 
   --with-cxx \
   --without-ffmpeg \
+
   --enable-largefile \
   --with-gdal=/usr/local/bin/gdal-config \
+
   --with-proj --with-proj-share=/usr/share/proj \
   --without-odbc \
+
   --with-gdal=/usr/bin/gdal-config \
 
   --with-sqlite \
 
   --with-sqlite \
  --with-postgres \
 
  --without-mysql \
 
  --with-nls \
 
 
   --with-python \
 
   --with-python \
   --with-cairo \
+
   --with-cairo --with-cairo-ldflags=-lfontconfig \
 +
  --with-freetype --with-freetype-includes=/usr/include/freetype2 \
 
   --with-wxwidgets=/usr/bin/wx-config \
 
   --with-wxwidgets=/usr/bin/wx-config \
   --without-fftw \
+
   --with-openmp \
   --with-freetype --with-freetype-includes=/usr/include/freetype2 \
+
  --with-blas --with-blas-includes=/usr/include/atlas-x86_64-base/ \
   --enable-largefile \
+
   --with-lapack --with-lapack-includes=/usr/include/atlas-x86_64-base/ \
   --with-pthread
+
  --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/grass78 -gui
 +
 
 +
In this case, for convenience, add it to the search path:
 +
    mkdir $HOME/bin
 +
    cd $HOME/bin
 +
    # example:
 +
    ln -s $HOME/software/grass78_release/bin.i686-pc-linux-gnu/grass78 .
 +
 
 +
Now use it subsequently with
 +
    grass78 -gui
 +
 
  
3. Hack the Makefile of GRASS-SWIG since python-config isn't there (add one line without the '+'):
+
'''Installation grass78 on a HPC system with '''Centos 7''' and no root privileges:'''
 +
This assumes that python3, fftw, proj, gdal and geos are available on the HPC system, either as modules or as installed software.
  
  svn diff swig/
+
Download and prepare some dependencies (freetypes and zstd)
  Index: swig/python/Makefile
+
    mkdir -p $HOME/grass/freetypes
  ===================================================================
+
    cd $HOME/grass/freetypes
  --- swig/python/Makefile        (revision 38916)
+
    wget path/to/freetype-2.9.1.tar.gz
  +++ swig/python/Makefile        (working copy)
+
    tar -xf freetype-2.9.1.tar.gz
  @@ -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:
+
    mkdir $HOME/grass/zstd
 +
    cd mkdir $HOME/grass/zstd
 +
    wget path/to/v1.4.4/zstd-1.4.4.tar.gz
 +
    tar -xf zstd-1.4.4.tar.gz
 +
    make install PREFIX=./
  
  # edit include/Make/Platform.make
+
Add the ZSTD path to your LD_LIBRARY_PATH
  # and add manually the line
 
 
  PYTHONINC          = -I/usr/include/python2.4
 
  
5. Compile
+
    tee -a $HOME/.bashrc > /dev/null << EOT
     make
+
     export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/grass/zstd/zstd-1.4.4/lib
  or on multicore:
+
     EOT
     make -j4
 
  
6. Either install with "make install" or run directly from compile directory (substitute ARCH with i586 or x86_64):
+
The configure command could look like this
 +
    ./configure \
 +
        -prefix=$HOME/grass \
 +
        --enable-64bit --with-fftw-includes=/path/to/fftw/include/ \
 +
        --with-fftw-libs=/path/to/fftw/lib/ \
 +
        --with-freetype-includes=$HOME/grass/freetypes/freetype-2.9.1/include/ \
 +
        --with-netcdf --with-geos --with-blas --with-lapack --with-postgres \
 +
        --with-zstd-includes=$HOME/grass/zstd/zstd-1.4.4/lib/ \
 +
        --with-zstd-libs=$HOME/grass/zstd/zstd-1.4.4/lib/ \
 +
        --with-gdal=/path/to/gdal-config  # This could be the path to a gdal version compiled from source
  
     bin.$ARCH/grass70 -wx
+
Finally usual:
 +
     make; make install
  
 
===== Gentoo =====
 
===== Gentoo =====
  
See http://gentoo-portage.com/sci-geosciences/grass
+
  ./configure \
 +
    --with-freetype=yes --with-freetype-includes="/usr/include/freetype2/"
 +
 
 +
See also http://packages.gentoo.org/package/sci-geosciences/grass
 +
 
 +
===== Funtoo =====
 +
 
 +
{{MovedToTrac|FuntooLinux}}
  
 
===== Fedora =====
 
===== Fedora =====
  
Ingredients:
+
====== GRASS GIS 6 on Fedora ======
  
  yum install proj-devel libjpeg-devel gdal-devel sqlite-devel ffmpeg-devel mesa-libGL-devel \
+
'''Preparation''' for the compilation of GRASS GIS 6 source code (F16-F21):
              mesa-libGLU-devel libXmu-devel tcl-devel fftw-devel lesstif-devel python-devel \
 
              wxPython wxGTK-devel bison flex ncurses-devel proj-epsg proj-nad xml2
 
  
''Note 1: that currently gdal-devel has (too) many dependencies and will lead to a massive download of extra packages (200 on a fresh Fedora 16 install).''
+
  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 2: ffmpeg-devel comes from the rpmfusion-free repository.''
+
''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.''
  
This is an example how to compile GRASS 6 on a 32bit Fedora system:
+
''Note 2: the optional ffmpeg-devel comes from the rpmfusion-free repository ([http://rpmfusion.org/Configuration/ configuration]).''
 +
 
 +
'''Download''' the source code:
 +
* GRASS GIS 6: [http://grass.osgeo.org/download/software/sources/ release package] - [http://grass.osgeo.org/grass64/source/snapshot/ weekly snapshot] - [http://trac.osgeo.org/grass/wiki/DownloadSource#GRASS6.4 SVN repository]
 +
 
 +
'''Configure''': This is an ''example'' how to configure the source code on a Fedora system:
  
 
   ./configure \
 
   ./configure \
Line 570: Line 876:
 
   --with-sqlite \
 
   --with-sqlite \
 
   --with-nls \
 
   --with-nls \
 +
  --with-geos \
 
   --with-wxwidgets=/usr/bin/wx-config \
 
   --with-wxwidgets=/usr/bin/wx-config \
  --with-fftw \
 
 
   --with-python=/usr/bin/python-config \
 
   --with-python=/usr/bin/python-config \
 
   --with-freetype --with-freetype-includes=/usr/include/freetype2 \
 
   --with-freetype --with-freetype-includes=/usr/include/freetype2 \
 
   --enable-largefile \
 
   --enable-largefile \
   --without-odbc
+
   --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.8+ source code (F20-F30):
 +
 
 +
  dnf install gcc gcc-c++ bison flex ncurses-devel gettext proj-epsg proj-devel proj-nad \
 +
              gdal gdal-devel sqlite-devel xml2 mesa-libGL-devel \
 +
              fftw-devel mesa-libGLU-devel libXmu-devel libX11-devel geos geos-devel \
 +
              libtiff-devel python3-devel numpy wxPython wxGTK3-devel subversion \
 +
              python3-dateutil python3-imaging python3-matplotlib-wx doxygen python3-sphinx \
 +
              libzstd-devel libzstd python3-six python3-numpy python3-wxpython4 \
 +
              proj-datumgrid proj-datumgrid-europe proj-datumgrid-north-america proj-datumgrid-world proj-datumgrid-oceania
 +
 
 +
  # optionally also:  netcdf-devel postgresql-devel
 +
  #                  atlas-devel lapack-devel lapack-devel
 +
  #                  laszip laszip-devel
 +
 
 +
''Note 1: the optional ffmpeg-devel comes from the rpmfusion-free repository ([http://rpmfusion.org/Configuration/ configuration]).''
 +
 
 +
 
 +
'''Download''' the source code:
 +
* GRASS GIS 7: [https://grass.osgeo.org/grass78/source/snapshot/ weekly snapshot] - [http://trac.osgeo.org/grass/wiki/DownloadSource#GRASS7 GitHub repository]
 +
 
  
This is an example how to compile GRASS 6 on a 64bit Fedora system:
+
'''Configure''': This is an example how to configure the source code on a Fedora system:
  
 
   ./configure \
 
   ./configure \
Line 583: Line 928:
 
   --with-gdal=/usr/bin/gdal-config \
 
   --with-gdal=/usr/bin/gdal-config \
 
   --with-proj --with-proj-share=/usr/share/proj \
 
   --with-proj --with-proj-share=/usr/share/proj \
 +
  --with-geos \
 
   --with-sqlite \
 
   --with-sqlite \
 
   --with-nls \
 
   --with-nls \
 
   --with-wxwidgets=/usr/bin/wx-config \
 
   --with-wxwidgets=/usr/bin/wx-config \
 
   --with-fftw \
 
   --with-fftw \
   --with-python=/usr/bin/python-config \
+
   --with-cairo --with-cairo-ldflags=-lfontconfig \
 
   --with-freetype --with-freetype-includes=/usr/include/freetype2 \
 
   --with-freetype --with-freetype-includes=/usr/include/freetype2 \
 +
  --enable-largefile \
 
   --without-odbc
 
   --without-odbc
  
An effective (but not fast) way of getting dependencies is to decide what to enable in the configuration, and then run ./config and see which files are missing. The package providing it can be found via:
+
''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/ \
 +
 
 +
''Extra 3:'' For '''ZSTD support''' (Zstandard compression algorithm), first install "dnf install libzstd libzstd-devel zstd". After installing the zstd related packages, add to the configuration lines above:
 +
  --with-zstd \
 +
 
 +
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:
 +
 
 +
''Application:Geo'' repo to be added (see [https://software.opensuse.org//download.html?project=Application%3AGeo&package=gdal Install package Application:Geo]
 +
 
 +
<source lang="bash">
 +
# example for Leap 42 version:
 +
sudo zypper addrepo http://download.opensuse.org/repositories/Application:Geo/openSUSE_Leap_42.3/Application:Geo.repo
 +
sudo zypper refresh
 +
</source>
 +
 
 +
RPM packages to be installed:
 +
<source lang="bash">
 +
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>
 +
 
 +
Source code configuration:
 +
<source lang="bash">
 +
./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
 +
</source>
 +
 
 +
Then compile with "make [-j2]".
 +
 
 +
===== Arch Linux =====
 +
 
 +
* <big>'''Easiest method : use AUR (Arch User Repository) package'''</big>
 +
Up-to-date links to Arch Linux GRASS PKGBUILDs are on https://grass.osgeo.org/download/software/linux/.
 +
 
 +
Please note that at this time AUR package has a problem : a symlink of python2 is created to work with grass whereas executable script call python3 ... Workaround is to comment symlink in AUR GRASS PKGBUILD
 +
 
 +
* <big>'''Compile from source code'''</big>
 +
If you want to compile it yourself, you could follow steps below :
 +
 
 +
Install dependencies :
 +
pacman -S bzip2 cairo fftw fontconfig freetype2 gcc-libs gdal geos glibc glu libpng libtiff libx11 libgl netcdf pdal proj python-gdal python-numpy python-pillow python-wxpython readline zlib zstd
 +
 
 +
Download and extract sources : https://grass.osgeo.org/download/software/sources/
 +
 
 +
We can now start building GRASS 7
 +
 
 +
export PATH=~/usr/bin:$PATH && \
 +
./configure \
 +
--enable-debug \
 +
--with-readline \
 +
--with-freetype=yes \
 +
--with-freetype-includes="/usr/include/freetype2/" \
 +
--with-geos \
 +
--with-odbc \
 +
--with-pthread \
 +
--with-fftw-includes="/usr/include/" \
 +
--with-fftw-libs=/usr/lib/ \
 +
--with-wxwidgets \
 +
--with-postgres \
 +
--with-pdal \
 +
--with-netcdf \
 +
--with-bzlib \
 +
--with-zstd
 +
 
 +
Now let's compile and install it
  
  yum provides */<name of the file>
+
  make
 +
make install
  
and then installed with your favourite package manager frontend.
+
 
 +
It's done, you can enjoy GRASS 7 in Arch, just type "grass78" (Please adjust version after grass) in the terminal to launch it.
  
 
===== RPM SPEC files =====
 
===== RPM SPEC files =====
* ... can be found in the source code, rpm/ directory,
+
* [https://build.opensuse.org/package/show?package=grass&project=Application%3AGeo OpenSuSe]
* or [https://build.opensuse.org/package/show?package=grass&project=Application%3AGeo OpenSuSe]
+
* [http://pkgs.fedoraproject.org/cgit/rpms/grass.git/tree/grass.spec Fedora]
* or [https://admin.fedoraproject.org/pkgdb/acls/name/grass Fedora]
+
* ...
* or [http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/grass/ Mandriva] (there are also [http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/proj/ proj4], [http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/geos/ geos], [http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/gdal/ gdal], [http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/gdal-grass/ gdal-grass-plugin], [http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/qgis/ qgis] etc)
 
  
 
===== Zaurus =====
 
===== Zaurus =====
Line 607: Line 1,062:
 
... see [http://wiki.debian.org/?GrassGISonZaurus here] for instructions
 
... see [http://wiki.debian.org/?GrassGISonZaurus here] for instructions
  
==== Mac OSX ====
+
==== macOS ====
  
* see the source/macosx readme
+
Compiling GRASS GIS for macOS is not fundamentally different from for other *nix systems. It is on the contrary quite similar, but what differ is the lack of a default package management system for software GRASS GIS depends on. This leaves the mac user to either: (1) compile the dependencies one-by-one; (2) using the [http://www.kyngchaos.com/software/frameworks/ frameworks] generously shared by William Kyngesburye; (3) compiling with one of the third-party package management systems avaliable; or (4) a combination thereof.
* also see [[Compiling on MacOSX]]
+
 
* some notes on [[Packaging on MacOSX]]
+
If you are interested in installing a precompiled version, please check out the [https://grass.osgeo.org/download/software/mac-osx/ official download site].
* Download [http://www.kyngchaos.com/software/frameworks#build_scripts build scripts]
+
 
 +
===== Compilation and installation =====
 +
 
 +
For more up-to-date instructions please read:
 +
 
 +
* [[Compiling on macOS using Anaconda]]
 +
* [[Compiling on macOS using Homebrew]]
 +
* [[Compiling on macOS using MacPorts]]
 +
 
 +
===== Legacy instructions =====
 +
 
 +
The following compilation and installation instructions are rather outdated as a whole. They do, however, contain parts and snippets that still may be very instructive and useful.
 +
 
 +
* [[Compiling on MacOSX]]
 +
* [[Compiling on MacOSX using Fink]]
 +
* [https://web.archive.org/web/20180718005252/http://www.kyngchaos.com/software/frameworks#build_scripts build scripts for dependencies]
 +
 
 +
Troubleshooting:
 +
* solving errors at starting GRASS GIS: [[MacOSX GRASS errors]]
 +
 
 +
==== 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 [http://www.freebsd.org/ports/ ports for FreeBSD] and [http://www.pkgsrc.org/ 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 ====
 
==== Solaris ====
  
 
* ''2008 Oct 15'': see [http://lists.osgeo.org/pipermail/grass-user/2008-October/047093.html this post on the grass mailing list]
 
* ''2008 Oct 15'': see [http://lists.osgeo.org/pipermail/grass-user/2008-October/047093.html 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 [http://www.opencsw.org/ 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 [http://www.opencsw.org/use-it/ OpenCSW documentation].
  
 
===== 10 SPARC/i86pc =====
 
===== 10 SPARC/i86pc =====
Line 665: Line 1,161:
 
==== AIX ====
 
==== AIX ====
  
 +
A recent [ftp://ftp.gnu.org/gnu/make/ GNU make] (>= 3.81) and GNU coreutils are required. These are available with the [http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/download.html IBM AIX toolbox] or through third-party AIX software repositories, e.g. [http://www.bullfreeware.com/ bullfreeware] and [http://www.perzl.org/aix/ perzl.org]. Note that 'make' does not work, only 'gmake' works.
 +
 +
General instructions to compile on AIX are e.g. [http://www.perzl.org/aix/index.php?n=Main.Instructions here]
 +
 +
On AIX, compilation results by default in 32 bit applications and static libraries. The [http://www.ibm.com/developerworks/aix/library/au-gnu.html IBM documentation] explains how to build 64 bit applications and shared libraries with GCC.
 +
 +
'''GRASS 6: Using the IBM xlc compiler:'''
 
* ''see [http://thread.gmane.org/gmane.comp.gis.grass.user/32667 this mailing list thread]''
 
* ''see [http://thread.gmane.org/gmane.comp.gis.grass.user/32667 this mailing list thread]''
  
Mike wrote:
+
Mike wrote in 2009:
<pre>
+
 
 
After attempting all the suggestions, I finally used
 
After attempting all the suggestions, I finally used
 
--disable-shared on the configure command, and all but
 
--disable-shared on the configure command, and all but
Line 676: Line 1,179:
  
 
The environment variables and configure command that worked were:
 
The environment variables and configure command that worked were:
 
+
<pre>
 +
# xlc compiler:
 
export PATH=/usr/local/bin:/opt/freeware/bin:$PATH
 
export PATH=/usr/local/bin:/opt/freeware/bin:$PATH
 
export OBJECT_MODE=64
 
export OBJECT_MODE=64
Line 704: Line 1,208:
 
   --with-tcltk-libs=/usr/local/lib \
 
   --with-tcltk-libs=/usr/local/lib \
 
   --with-opengl-includes=/usr/include/GL
 
   --with-opengl-includes=/usr/include/GL
 +
</pre>
 +
 +
'''GRASS 7: Using the IBM xlc compiler:'''
 +
 +
Get and install (in this order):
 +
* [ftp://ftp.gnu.org/gnu/tar/ GNU tar]
 +
* [ftp://ftp.gnu.org/gnu/make/ GNU make] (>= 3.81)
 +
* [http://www.sqlite.org SQLite]
 +
* [http://trac.osgeo.org/proj/ PROJ.4] (for ./configure parameters, see [[Talk:Compile and Install|here]])
 +
* [http://www.gdal.org GDAL] (for ./configure parameters, see [[Talk:Compile and Install|here]])
 +
* [http://grass.osgeo.org/grass74/source/snapshot/ GRASS GIS 7]
 +
 +
The environment variables and configure command that worked:
 +
<pre>
 +
## 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
 +
</pre>
 +
 +
'''GRASS 7: Using the GNU gcc compiler:'''
 +
 +
Get and install (in this order):
 +
* if needed, [ftp://ftp.gnu.org/gnu/tar/ GNU tar]
 +
* if needed (the name is often 'gmake' and not 'make') [ftp://ftp.gnu.org/gnu/make/ GNU make] (>= 3.81)
 +
* [http://www.sqlite.org SQLite]
 +
* [http://trac.osgeo.org/proj/ PROJ.4] (for ./configure parameters, see [[Talk:Compile and Install|here]])
 +
* [http://www.gdal.org GDAL] (for ./configure parameters, see [[Talk:Compile and Install|here]])
 +
* [http://grass.osgeo.org/grass74/source/snapshot/ GRASS GIS 7]
 +
 +
The environment variables and configure command that worked for AIX 5.x:
 +
<pre>
 +
## 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
 +
</pre>
 +
 +
The environment variables and configure command that worked for AIX 7.x:
 +
<pre>
 +
## 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
 
</pre>
 
</pre>
  
Line 710: Line 1,315:
 
===== MS-Windows/Cygwin =====
 
===== MS-Windows/Cygwin =====
  
... see [http://grass.itc.it/platforms/wingrass.html here] (should be moved to the Wiki)
+
* See the [[Cygwin]] wiki pages
  
 
===== MS-Windows/native =====
 
===== MS-Windows/native =====
Line 716: Line 1,321:
 
====== Compile ======
 
====== Compile ======
  
* [http://www.webalice.it/marco.pasetti/grass/BuildFromSource.html GRASS Windows Native Binary Building Guide] (GRASS 6.3.x)
+
* [http://trac.osgeo.org/grass/wiki/CompileOnWindows GRASS Windows Native Binary Building Guide] (GRASS 6.4.x + 7.x)
* [http://trac.osgeo.org/grass/wiki/CompileOnWindows GRASS Windows Native Binary Building Guide] (GRASS 6.4.x)
+
* <strike>[http://www.webalice.it/marco.pasetti/grass/BuildFromSource.html GRASS Windows Native Binary Building Guide] (GRASS 6.3.x) </strike>
 
* See/adapt [http://blog.qgis.org/node/124 idea] for unattended install of QGIS (et al) from [http://trac.osgeo.org/osgeo4w/ OSGeo4W] from the QuantumGIS Blog.
 
* See/adapt [http://blog.qgis.org/node/124 idea] for unattended install of QGIS (et al) from [http://trac.osgeo.org/osgeo4w/ OSGeo4W] from the QuantumGIS Blog.
  
Line 733: Line 1,338:
 
** 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.
 
** 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.
 
** 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 ===
 
=== Optimization ===
Line 797: Line 1,411:
 
== Addons ==
 
== Addons ==
  
=== Compiled C modules ===
+
Please note that the installation of [[AddOns/GRASS_6|Addons]] can be easily done with the {{cmd|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:'''
 
'''Requirements:'''
Line 809: Line 1,427:
 
Each of the [[GRASS_AddOns|addon]] modules should come with a Makefile. To compile it, just run:
 
Each of the [[GRASS_AddOns|addon]] modules should come with a Makefile. To compile it, just run:
 
     make MODULE_TOPDIR=/path/to/grass64/
 
     make MODULE_TOPDIR=/path/to/grass64/
 +
 +
Note that the <tt>/path/to/grass64</tt> has to be absolute, not relative.
  
 
If using Bash it may be useful to set that up as an alias:
 
If using Bash it may be useful to set that up as an alias:

Latest revision as of 11:11, 27 September 2020


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...

Contents

How to do compilation and installation of GRASS GIS?

Here we explain the procedure to compile GRASS from GitHub, but it also applies to official GRASS 7 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 GIS needs at least two extra libraries: PROJ and GDAL/OGR. It is recommended to download them as ready-to-use packages for your software platform (Linux distribution, Windows, Mac...).

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

To compile, you will also need the respective "-devel" packages; see below for details.

Download GRASS GIS source code

First, download the GRASS GIS source code.

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 grass7'
     su -c 'chown yourlogin:yourgroup grass7'

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

     mkdir $HOME/src
     cd $HOME/src/
     git clone https://github.com/OSGeo/grass.git grass_master
  • 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-python \
         --with-geos \
         --with-gdal=/usr/bin/gdal-config \
         --with-cairo --with-cairo-ldflags=-lfontconfig \
         --with-freetype \
         --with-freetype-includes=/usr/include/freetype2 \
         --with-proj --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:  x86_64-pc-linux-gnu
 
 Source directory:           /home/user/software/grass_master
 Build directory:            /home/user/software/grass_master
 Installation directory:     ${prefix}/grass79
 Startup script in directory:${exec_prefix}/bin
 C compiler:                 gcc -O2 -march=native -std=gnu99 -fexceptions -fstack-protector -m64 -fdiagnostics-color 
 C++ compiler:               c++ -g -Wall
 Building shared libraries:  yes
 OpenGL platform:            X11
 
 MacOSX application:         no
 MacOSX architectures:       
 MacOSX SDK:                 
 
 BLAS support:               yes
 BZIP2 support:              no
 C++ support:                yes
 Cairo support:              yes
 DWG support:                no
 FFTW support:               yes
 FreeType support:           yes
 GDAL support:               yes
 GEOS support:               yes
 [...]
  • Let's compile it (takes a little while...)!
     make -j2
  • 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: Mon 19 Aug 2019 10:47:57 PM CEST
--
Errors in:
No errors detected.
--
Finished compilation: Mon 19 Aug 2019 10:55:12 PM CEST
(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 occurring 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:
     grass79

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

Linux comes in various flavours, i.e. distributions.

Distribution related packaging
Generic procedure for Debian-based distributions (Ubuntu, ...)

WORK IN PROGRESS

1. Install official GRASS package

sudo apt install grass grass-dev

2. Enable source code download

# do backup first
sudo cp /etc/apt/sources.list /etc/apt/sources.list.orig
sudo sed -i '/^#\sdeb-src /s/^# *//' /etc/apt/sources.list

3. Install GRASS dependencies

sudo apt build-dep grass

4. Download GRASS source code

git clone https://github.com/osgeo/grass

5. Compile GRASS from source code

cd grass

Configure:

grass --config build | sh

Optionally install missing dependecies (can happen when official GRASS package is not compatible with GRASS master), eg.

sudo apt install libzstd-dev

Compile:

make -j2

6. Run locally or install

./bin.x86_64-pc-linux-gnu/grass79 --version

or

sudo make install
grass79 --version
Debian
  • Official DebianGIS packaging control files, 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
  1. 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
  1. 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/grass72
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/grass78/source/grass-7.8.0.tar.gz
tar -zxvf grass-7.8.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 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/grass74/source/grass-7.4.0.tar.gz
tar xzfv grass-7.4.0.tar.gz
cd grass-7.4.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/grass74
GRASS 7 on Debian Stretch

(Updated from above with package changes required for Debian Stretch)

Install needed packages for GRASS 7.2 - 7.6:

 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 python-wxtools wx-common zlib1g-dev netcdf-bin \
   libnetcdf-dev libgegl-dev  doxygen python-sphinx postgresql libgeotiff-dev libblas-dev \
   mariadb-server libatlas-dev liblapack3 liblapack-dev opencl-headers ocl-icd-libopencl1 \
   subversion liblas-bin liblas-c-dev python-gdal libpdal-dev libpdal-plugin-python pdal

Install needed packages for GRASS 7.8+ (Python 3 support!):

 apt-get install cmake libboost-all-dev flex bison debhelper dpatch autoconf2.13 autotools-dev \
   g++ gcc gettext graphviz libcairo2-dev libfftw3-dev libfreetype6-dev libgdal20 python3-dev \
   libgdal-dev libglu1-mesa-dev libglw1-mesa-dev libproj-dev libreadline-dev libgeos-c1v5 \
   libsqlite3-dev libtiff5-dev libwxgtk3.0-dev libxmu-dev libxmu-headers libxt-dev mesa-common-dev \
   proj-bin proj-data python3-numpy python3-six wx-common zlib1g-dev netcdf-bin \
   libnetcdf-dev libgegl-dev  doxygen python3-sphinx postgresql libgeotiff-dev libblas-dev \
   libatlas-dev liblapack3 liblapack-dev opencl-headers ocl-icd-libopencl1 \
   subversion liblas-bin liblas-c-dev python3-gdal libpdal-dev libpdal-plugin-python pdal
   
   # ? python3-wxgtk4.0 libmariadb

Download and unpack source code or fetch from GitHub: https://github.com/OSGeo/grass

Configuration:

 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 \
  --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

Compile:

 make -j2

Install:

 make install
GRASS 7 on Debian Buster

-- To be updated --

Install needed packages for GRASS 7.8+ (Python 3 support!):

 apt-get install cmake libboost-all-dev flex bison debhelper dpatch autoconf2.13 autotools-dev \
   g++ gcc gettext graphviz libcairo2-dev libfftw3-dev libfreetype6-dev libgdal20 python3-dev \
   libgdal-dev libglu1-mesa-dev libglw1-mesa-dev libproj-dev libreadline-dev libgeos-c1v5 \
   libsqlite3-dev libtiff5-dev libwxgtk3.0-dev libxmu-dev libxmu-headers libxt-dev mesa-common-dev \
   proj-bin proj-data python3-numpy python3-six wx-common zlib1g-dev netcdf-bin \
   libnetcdf-dev libgegl-dev  doxygen python3-sphinx postgresql libgeotiff-dev libblas-dev \
   liblapack3 liblapack-dev opencl-headers ocl-icd-libopencl1 \
   subversion liblas-bin liblas-c-dev python3-gdal libpdal-dev libpdal-plugin-python pdal \
   python3-wxgtk4.0 default-libmysqlclient-dev

Download and unpack source code or fetch from GitHub: https://github.com/OSGeo/grass

Configuration:

 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 \
  --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

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. However, here is a short guide for Mint:

# Linux Mint 20

# be sure to have an updated system
sudo apt-get update && sudo apt-get upgrade -y

# installation of required libraries and compile tools
# recommended to give Python3 precedence over Python2 (which is end-of-life since 2019)
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1

# install compiler tools and further dependencies (tested with Linux Mint 20)
# this is a single command, please copy-paste it entirely into the terminal:
sudo apt-get install \
  build-essential \
  flex make bison gcc libgcc1 g++ cmake ccache \
  libproj-dev proj-data proj-bin \
  libgeos-dev \
  libgdal-dev python3-gdal gdal-bin \
  python3 python3-dev \
  python3-opengl \
  python-wxversion python-wxtools python-wxgtk3.0 python3-wxgtk4.0 \
  python3-dateutil libgsl-dev python3-numpy \
  wx3.0-headers wx-common libwxgtk3.0-gtk3-dev libwxbase3.0-dev \
  libncurses5-dev zlib1g-dev gettext \
  libbz2-dev libzstd-dev libfreetype6-dev \
  libtiff5-dev libpnglite-dev libcairo2 libcairo2-dev \
  sqlite3 libsqlite3-dev libpq-dev \
  libfftw3-3 libfftw3-dev \
  libboost-thread-dev libboost-program-options-dev \
  subversion \
  checkinstall \
  libglu1-mesa-dev libxmu-dev \
  ghostscript wget -y

Next steps:

  • download GRASS GIS source code (e.g. take the "7.x-git snapshot")
  • unpack source code
  • change into the source code directory
# in the source code directory, "configure" the source code to prepare for compilation:
./configure \
  --with-cxx \
  --enable-largefile \
  --with-proj --with-proj-share=/usr/share/proj \
  --with-gdal=/usr/bin/gdal-config \
  --with-python \
  --with-geos \
  --with-sqlite \
  --with-nls \
  --with-zstd \
  --with-cairo --with-cairo-ldflags=-lfontconfig \
  --with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
  --with-wx=/usr/bin/wx-config \
  --with-wxwidgets \
  --with-fftw \
  --with-opengl-libs=/usr/include/GL \
  --without-postgres \
  --without-pdal \
  --without-motif \
  --without-netcdf \
  --without-mysql \
  --without-odbc \
  --without-openmp \
  --without-ffmpeg

# compile GRASS GIS
make -j2

# install compiled GRASS GIS on system
sudo make install

# use GRASS GIS! Start on command line
grass78
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

Preparation Centos 8 | Scientific Linux 8:

 dnf install epel-release
 dnf install flex bison make zlib-devel gcc-c++ gettext \
             fftw-devel libtiff-devel sqlite-devel \
             proj proj-devel proj-datumgrid libxml2 \
             geos geos-devel git \
             netcdf netcdf-devel atlas-devel \
             blas-devel lapack-devel libpq-devel \
             python3-devel python3-numpy \
             python3-dateutil python3-imaging python3-matplotlib \
             gdal gdal-libs gdal-python-tools python3-gdal gdal-devel \
             wxGTK3-devel mesa-libGL-devel mesa-libGLU-devel \
             libXmu-devel libX11-devel

GRASS GIS 7 compilation and installation

Download source code (e.g., --> "Download latest 7.8 code)" 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/grass78 -gui

In this case, for convenience, add it to the search path:

   mkdir $HOME/bin
   cd $HOME/bin
   # example:
   ln -s $HOME/software/grass78_release/bin.i686-pc-linux-gnu/grass78 .

Now use it subsequently with

   grass78 -gui


Installation grass78 on a HPC system with Centos 7 and no root privileges: This assumes that python3, fftw, proj, gdal and geos are available on the HPC system, either as modules or as installed software.

Download and prepare some dependencies (freetypes and zstd)

   mkdir -p $HOME/grass/freetypes
   cd $HOME/grass/freetypes
   wget path/to/freetype-2.9.1.tar.gz
   tar -xf freetype-2.9.1.tar.gz
   mkdir $HOME/grass/zstd
   cd mkdir $HOME/grass/zstd
   wget path/to/v1.4.4/zstd-1.4.4.tar.gz
   tar -xf zstd-1.4.4.tar.gz
   make install PREFIX=./

Add the ZSTD path to your LD_LIBRARY_PATH

   tee -a $HOME/.bashrc > /dev/null << EOT
   export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/grass/zstd/zstd-1.4.4/lib
   EOT

The configure command could look like this

   ./configure \
       -prefix=$HOME/grass \
       --enable-64bit --with-fftw-includes=/path/to/fftw/include/ \
       --with-fftw-libs=/path/to/fftw/lib/ \
       --with-freetype-includes=$HOME/grass/freetypes/freetype-2.9.1/include/ \
       --with-netcdf --with-geos --with-blas --with-lapack --with-postgres \
       --with-zstd-includes=$HOME/grass/zstd/zstd-1.4.4/lib/ \
       --with-zstd-libs=$HOME/grass/zstd/zstd-1.4.4/lib/ \
       --with-gdal=/path/to/gdal-config  # This could be the path to a gdal version compiled from source

Finally usual:

   make; make install
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:

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.8+ source code (F20-F30):

 dnf install gcc gcc-c++ bison flex ncurses-devel gettext proj-epsg proj-devel proj-nad \
             gdal gdal-devel sqlite-devel xml2 mesa-libGL-devel \
             fftw-devel mesa-libGLU-devel libXmu-devel libX11-devel geos geos-devel \
             libtiff-devel python3-devel numpy wxPython wxGTK3-devel subversion \
             python3-dateutil python3-imaging python3-matplotlib-wx doxygen python3-sphinx \
             libzstd-devel libzstd python3-six python3-numpy python3-wxpython4 \
             proj-datumgrid proj-datumgrid-europe proj-datumgrid-north-america proj-datumgrid-world proj-datumgrid-oceania
 # optionally also:  netcdf-devel postgresql-devel 
 #                   atlas-devel lapack-devel lapack-devel 
 #                   laszip laszip-devel

Note 1: the optional ffmpeg-devel comes from the rpmfusion-free repository (configuration).


Download the source code:


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-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/ \

Extra 3: For ZSTD support (Zstandard compression algorithm), first install "dnf install libzstd libzstd-devel zstd". After installing the zstd related packages, add to the configuration lines above:

 --with-zstd \

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:

Application:Geo repo to be added (see Install package Application:Geo

# example for Leap 42 version:
sudo zypper addrepo http://download.opensuse.org/repositories/Application:Geo/openSUSE_Leap_42.3/Application:Geo.repo
sudo zypper refresh

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
  • Easiest method : use AUR (Arch User Repository) package

Up-to-date links to Arch Linux GRASS PKGBUILDs are on https://grass.osgeo.org/download/software/linux/.

Please note that at this time AUR package has a problem : a symlink of python2 is created to work with grass whereas executable script call python3 ... Workaround is to comment symlink in AUR GRASS PKGBUILD

  • Compile from source code

If you want to compile it yourself, you could follow steps below :

Install dependencies :

pacman -S bzip2 cairo fftw fontconfig freetype2 gcc-libs gdal geos glibc glu libpng libtiff libx11 libgl netcdf pdal proj python-gdal python-numpy python-pillow python-wxpython readline zlib zstd

Download and extract sources : https://grass.osgeo.org/download/software/sources/

We can now start building GRASS 7

export PATH=~/usr/bin:$PATH && \
./configure \
--enable-debug \
--with-readline \
--with-freetype=yes \
--with-freetype-includes="/usr/include/freetype2/" \
--with-geos \
--with-odbc \
--with-pthread \
--with-fftw-includes="/usr/include/" \
--with-fftw-libs=/usr/lib/ \
--with-wxwidgets \
--with-postgres \
--with-pdal \
--with-netcdf \
--with-bzlib \
--with-zstd

Now let's compile and install it

make
make install


It's done, you can enjoy GRASS 7 in Arch, just type "grass78" (Please adjust version after grass) in the terminal to launch it.

RPM SPEC files
Zaurus

... see here for instructions

macOS

Compiling GRASS GIS for macOS is not fundamentally different from for other *nix systems. It is on the contrary quite similar, but what differ is the lack of a default package management system for software GRASS GIS depends on. This leaves the mac user to either: (1) compile the dependencies one-by-one; (2) using the frameworks generously shared by William Kyngesburye; (3) compiling with one of the third-party package management systems avaliable; or (4) a combination thereof.

If you are interested in installing a precompiled version, please check out the official download site.

Compilation and installation

For more up-to-date instructions please read:

Legacy instructions

The following compilation and installation instructions are rather outdated as a whole. They do, however, contain parts and snippets that still may be very instructive and useful.

Troubleshooting:

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

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 ([1], CSW pkg, installs in /opt/csw/) or Sunfreeware ([2], 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 ([3]). 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, [4]).
  • compile and install any additional libraries (e. g. GEOS, [5]).
  • 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):

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):

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
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
  • 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