Difference between revisions of "Compile and Install Ubuntu"

From GRASS-Wiki
Jump to: navigation, search
(Dependencies: numpy dependency)
(Updates for Ubuntu 20.10)
 
(181 intermediate revisions by 12 users not shown)
Line 1: Line 1:
{{MoveToTrac}}
+
<div class="boilerplate metadata" id="attention" style="-moz-border-radius:30px; border: 1px double #35824B; margin-bottom: 1.5em; padding: 1em; background-color: #f9f9f9;">
 +
<p style="font-size: 150%; text-align: left;"><span style="color:#35824B">'''Attention'''</span>&nbsp;</p><span style="color:#333333">'''The following instructions describe the compilation and installation of 7.x and its required dependencies completely from the source on Ubuntu based systems. Please, prefer pre-compiled packages over the manual way described below unless you know ''what'' and ''how'', you want to learn and help testing.'''</span>
 +
</div>
  
The following instructions describe the compilation and installation of GRASS 6.x (or even 7) and its required dependencies completely from the source on Ubuntu based systems. Some things change fast and therefore it is expected that the instructions might fail. Please inform the grass-user list in case something just does not work (like for example non-available dependecies/packages from the repositories) or update the wiki respectively.
+
== Very Important notes ==
 +
 
 +
* '''Pre-compiled packages and backports''' are available from [https://wiki.ubuntu.com/UbuntuGIS UbuntuGIS] via their [https://launchpad.net/~ubuntugis/+archive/ppa/ ppa.launchpad] repositories. '''This is by far the simplest and fastest solution. Please prefer it over the manual way of compiling source code yourself as described below.'''
 +
** Daily ready to installl GRASS GIS builds of the 7.x release branch and trunk are available from ''ppa:grass/grass-devel''
 +
**: <source lang=bash>sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable</source>
 +
**: <source lang=bash>sudo add-apt-repository ppa:grass/grass-devel</source>
 +
** Latest version of GRASS 7.x is available from ''ppa:grass/grass-stable''
 +
**: <source lang=bash>sudo add-apt-repository ppa:ubuntugis/ppa</source>
 +
**: <source lang=bash>sudo add-apt-repository ppa:grass/grass-stable</source>
 +
*: <source lang=bash>sudo apt-get update</source>
 +
*: <source lang=bash>sudo apt-get install grass76</source>
 +
 
 +
== Quick instructions ==
 +
 
 +
These instructions should work fine on Ubuntu distributions prior to release 20.04:
 +
 
 +
1. Install some dependencies (PROJ, GEOS, GDAL libraries) and the compiler tools <br />
 +
(note: for GRASS GIS 7.8+ you need Python 3!)
 +
 
 +
<source lang="bash">
 +
# be sure to have an updated system
 +
sudo apt-get update && sudo apt-get upgrade -y
 +
 
 +
# install PROJ
 +
sudo apt-get install libproj-dev proj-data proj-bin unzip -y
 +
 
 +
</source>
 +
<del># optionally, install (selected) datum grid files</del><br />
 +
<del># Future: The proj-datumgrid packages have been deprecated with PROJ 7.0.0+</del><br />
 +
<del>cd /tmp</del><br />
 +
<del>wget -c https://download.osgeo.org/proj/proj-datumgrid-world-latest.zip</del><br />
 +
<del>wget -c https://download.osgeo.org/proj/proj-datumgrid-oceania-latest.zip</del><br />
 +
<del>wget -c https://download.osgeo.org/proj/proj-datumgrid-north-america-latest.zip</del><br />
 +
<del>wget -c https://download.osgeo.org/proj/proj-datumgrid-europe-latest.zip</del><br />
 +
<del># unpack and remove zip files</del><br />
 +
<del>cd /usr/share/proj/</del><br />
 +
<del>for datumfile in $(ls /tmp/proj-datumgrid-*-latest.zip) ; do</del><br />
 +
<del>  sudo unzip $datumfile && rm -f $datumfile</del><br />
 +
<del>done</del><br />
 +
 
 +
<source lang="bash">
 +
# optionally, install (selected) datum grid files
 +
sudo apt-get install proj-data
 +
 
 +
# install GEOS
 +
sudo apt-get install libgeos-dev -y
 +
 
 +
# install GDAL
 +
sudo apt-get install libgdal-dev python3-gdal gdal-bin -y
 +
 
 +
# install PDAL (optional)
 +
sudo apt-get install libpdal-dev pdal libpdal-plugin-python -y
 +
 
 +
# 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 1
 +
</source>
 +
 
 +
Install compiler stuff and further dependencies.
 +
Note: this is a single command, please copy-paste it entirely into the terminal:
 +
 
 +
For Ubuntu 19.04 (see below for Ubuntu 20.04)
 +
<source lang="bash">
 +
sudo apt-get install \
 +
  build-essential \
 +
  flex make bison gcc libgcc1 g++ ccache \
 +
  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-dev \
 +
  libwxbase3.0-dev  \
 +
  libncurses5-dev \
 +
  libbz2-dev \
 +
  zlib1g-dev gettext \
 +
  libtiff5-dev libpnglite-dev \
 +
  libcairo2 libcairo2-dev \
 +
  sqlite3 libsqlite3-dev \
 +
  libpq-dev \
 +
  libreadline6-dev libfreetype6-dev \
 +
  libfftw3-3 libfftw3-dev \
 +
  libboost-thread-dev libboost-program-options-dev liblas-c-dev \
 +
  subversion libzstd-dev \
 +
  checkinstall \
 +
  libglu1-mesa-dev libxmu-dev \
 +
  ghostscript wget -y
 +
</source>
 +
 
 +
This are optional video codec libraries for NVIZ video output for Ubuntu 19.04:
 +
<source lang="bash">
 +
sudo apt-get install \
 +
  libav-tools libavutil-dev ffmpeg2theora \
 +
  libffmpegthumbnailer-dev \
 +
  libavcodec-dev \
 +
  libxmu-dev \
 +
  libavformat-dev libswscale-dev
 +
</source>
 +
 
 +
For Ubuntu 20.04:
 +
<source lang="bash">
 +
sudo apt-get install \
 +
  build-essential \
 +
  flex make bison gcc libgcc1 g++ ccache \
 +
  python3 python3-dev \
 +
  python3-opengl python3-wxgtk4.0 \
 +
  python3-dateutil libgsl-dev python3-numpy \
 +
  wx3.0-headers wx-common libwxgtk3.0-gtk3-dev \
 +
  libwxbase3.0-dev  \
 +
  libncurses5-dev \
 +
  libbz2-dev \
 +
  zlib1g-dev gettext \
 +
  libtiff5-dev libpnglite-dev \
 +
  libcairo2 libcairo2-dev \
 +
  sqlite3 libsqlite3-dev \
 +
  libpq-dev \
 +
  libreadline6-dev libfreetype6-dev \
 +
  libfftw3-3 libfftw3-dev \
 +
  libboost-thread-dev libboost-program-options-dev  libpdal-dev\
 +
  subversion libzstd-dev \
 +
  checkinstall \
 +
  libglu1-mesa-dev libxmu-dev \
 +
  ghostscript wget -y
 +
</source>
 +
 
 +
For NVIZ on Ubuntu 20.04:
 +
<source lang="bash">
 +
sudo apt-get install \
 +
  ffmpeg libavutil-dev ffmpeg2theora \
 +
  libffmpegthumbnailer-dev \
 +
  libavcodec-dev \
 +
  libxmu-dev \
 +
  libavformat-dev libswscale-dev
 +
</source>
 +
 
 +
Now we have all "ingredients" readily installed on our system.
 +
 
 +
'''Source code download''':
 +
 
 +
There a two ways of getting the source code: either use a) the weekly snapshot (cannot be updated, or b) the source code from the GitHub repository (you can update your local copy easily in future):
 +
 
 +
'''a) Download of the weekly source code snapshot (not recommended):'''
 +
<source lang="bash">
 +
# download latest GRASS GIS 7.x stable release source code:
 +
mkdir $HOME/src/
 +
cd  $HOME/src/
 +
wget https://grass.osgeo.org/grass78/source/snapshot/grass-7.8.git_src_snapshot_latest.tar.gz
 +
 
 +
# Unpack source code package and remove tarball archive:
 +
tar xvfz grass-7.8.git_src_snapshot_latest.tar.gz
 +
rm -f grass-7.8.git_src_snapshot_latest.tar.gz
 +
 
 +
# rename source code directory (yes, with the questionmarks!)
 +
mv grass-7.8.git_src_snapshot_20??_??_?? grass-7.8.latest
 +
cd grass-7.8.latest/
 +
</source>
 +
 
 +
'''b) Download of the current development version from GitHub (adopt the path below accordingly)'''
 +
<source lang="bash">
 +
git clone https://github.com/OSGeo/grass.git grass-7.8.latest.git
 +
cd grass-7.8.latest.git/
 +
git checkout releasebranch_7_8
 +
</source>
 +
 
 +
Now we can '''compile''' the source code in order to generate the GRASS GIS binaries:
  
* An alternate method is to use the DebianGIS packaging scripts, which enable a lot of this to happen automatically. see [https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4/debian/README.debian debian/README.debian] in the Subversion source code.
+
<source lang="bash">
 +
# "configure" source code for local machine (checks for CPU type etc):
 +
MYCFLAGS='-O2 -fPIC -fno-common -fexceptions -std=gnu99 -fstack-protector -m64'
 +
#MYCXXFLAGS=''
 +
MYLDFLAGS='-Wl,--no-undefined -Wl,-z,now'
  
 +
LDFLAGS="$MYLDFLAGS" CFLAGS="$MYCFLAGS" CXXFLAGS="$MYCXXFLAGS" ./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-liblas \
 +
  --with-pdal \
 +
  --with-cairo --with-cairo-ldflags=-lfontconfig \
 +
  --with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
 +
  --with-wxwidgets \
 +
  --with-fftw \
 +
  --with-motif \
 +
  --with-opengl-libs=/usr/include/GL \
 +
  --with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \
 +
  --without-netcdf \
 +
  --without-mysql \
 +
  --without-odbc \
 +
  --without-openmp \
 +
  --without-ffmpeg
 +
</source>
 +
For Ubuntu 20.04 remove --with-liblas :
 +
<source lang="bash">
 +
# "configure" source code for local machine (checks for CPU type etc):
 +
MYCFLAGS='-O2 -fPIC -fno-common -fexceptions -std=gnu99 -fstack-protector -m64'
 +
#MYCXXFLAGS=''
 +
MYLDFLAGS='-Wl,--no-undefined -Wl,-z,now'
  
== Very Important notes ==
+
LDFLAGS="$MYLDFLAGS" CFLAGS="$MYCFLAGS" CXXFLAGS="$MYCXXFLAGS" ./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-pdal \
 +
  --with-cairo --with-cairo-ldflags=-lfontconfig \
 +
  --with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
 +
  --with-wxwidgets \
 +
  --with-fftw \
 +
  --with-motif \
 +
  --with-opengl-libs=/usr/include/GL \
 +
  --with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \
 +
  --without-netcdf \
 +
  --without-mysql \
 +
  --without-odbc \
 +
  --without-openmp \
 +
  --without-ffmpeg
 +
</source>
 +
 
 +
 
 +
Now compile source code (takes some time as it generates binary code from the source code):
 +
<source lang="bash">
 +
# note: the more CPUs you have, the higher the -j number may be set to
 +
# here: build using 4 CPU cores
 +
make -j4
 +
</source>
  
* Pre-compiled packages and backports are available from [https://wiki.ubuntu.com/UbuntuGIS UbuntuGIS] via their [https://launchpad.net/~ubuntugis/+archive/ppa/ ppa.launchpad] repositories. This is by far the simplest and fastest solution.
+
Install resulting GRASS GIS 7 binaries into /usr/local/:
 +
<source lang="bash">
 +
sudo make install
 +
</source>
  
* To build an updated version of GRASS or support libraries unmodified, in most cases it will be easier to use an automated build tool such as ''pbuilder'', ''debuild'' or ''cowbuilder''. See the ''debian/'' directory in the source code for details.
+
Start GRASS GIS in the terminal:
 +
<source lang="bash">
 +
grass78
 +
</source>
  
* GRASS version 6.5 exists for development purposes for testing features to-be backported to version 6.4. As such it may include unstable code and is not intended for end-users.
+
'''Done & enjoy!'''
  
 
== Hints ==
 
== Hints ==
  
* Installation of a compiled code can be done by using the tool ''checkinstall'' (i.e., ''sudo checkinstall'' instead of ''sudo make install'') which makes removal of packages easier. If checkinstall fails to deliver please note a related bug: [https://bugs.launchpad.net/ubuntu/+source/checkinstall/+bug/78455 78455] and [https://bugs.launchpad.net/ubuntu/+source/checkinstall/+bug/599163 599163]. Useful information on the use of ''checkinstall'': [https://help.ubuntu.com/community/CompilingEasyHowTo Compiling things on Ubuntu the Easy Way].
+
* Usually, the installation of compiled code is done by using the <source lang="bash" enclose="none">make</source> tool. Alternatively, this can be done by using the ''checkinstall'' tool (i.e., <source lang="bash" enclose="none">sudo checkinstall</source>  instead of <source lang="bash" enclose="none">sudo make install</source>) which eases off removal of packages. If ''checkinstall'' fails to deliver, please note some related bugs: [https://bugs.launchpad.net/ubuntu/+source/checkinstall/+bug/78455 78455] and [https://bugs.launchpad.net/ubuntu/+source/checkinstall/+bug/599163 599163]. Useful information on using ''checkinstall'': [https://help.ubuntu.com/community/CompilingEasyHowTo Compiling things on Ubuntu the Easy Way].
  
* In multi-core processors compilation performance can be boosted with ''-j'' switches (e.g. ''make -j2'' or ''make -j4'') which specify the number of jobs (commands) to run simultaneously.
+
* In multi-core processors, the compilation performance can be boosted by using  ''-j'' switches (e.g. <source lang="bash" enclose="none">make -j2</source>  or  <source lang="bash" enclose="none">make -j3</source>  or even <source lang="bash" enclose="none">make -j4</source>) which specify the number of jobs (commands) to run simultaneously.
  
 
== Dependencies ==
 
== Dependencies ==
  
* update the system from the repositories
+
=== Current stable Ubuntu version ===
sudo apt-get update && sudo apt-get upgrade
+
First, update the system from the repositories<source lang="bash">
 +
sudo apt-get update && sudo apt-get upgrade
 +
</source>
 +
 
 +
Then, install ''SQLite'', ''SVN'' and ''dependencies'' for compiling PROJ, GEOS, GDAL/OGR, GRASS, GDAL-GRASS-PLUGIN (some additional packages may be required in this case); the following action will also install various dependencies (listed in the command line as <source lang="bash" enclose="none">The following extra packages will be installed:</source>...):<br/>
 +
 
 +
The following dependencies concern [http://releases.ubuntu.com/xenial/ Ubuntu Xenial Xerus (16.04 LTS)]
  
* install SQLite, SVN and dependencies for compiling PROJ, GEOS, GDAL/OGR, GRASS, GDAL-GRASS-PLUGIN; also install all extra packages queried for (''The following extra packages will be installed:''):
+
<source lang="bash">
sudo apt-get install \
+
# this is a single command, please copy-paste it entirely into the terminal:
 +
sudo apt-get install \
 
   build-essential \
 
   build-essential \
   make flex bison gcc libgcc1 g++ cmake ccache \
+
   flex make bison gcc libgcc1 g++ cmake ccache \
   swig swig1.3 \
+
   python python-dev \
  python python-dev python-qt4 python-qt4-dev \
+
   python-opengl \
   sip4 python-sip4 python-sip4-dev python-opengl \
+
   python-wxversion python-wxtools python-wxgtk3.0 \
   python-wxversion python-wxtools python-wxgtk2.8 \
+
   python-dateutil libgsl-dev python-numpy \
   python-dateutil libgsl0-dev python-numpy \
+
   wx3.0-headers wx-common libwxgtk3.0-dev \
   wx2.8-headers wx-common libwxgtk2.8-dev libwxgtk2.8-dbg \
+
   libwxbase3.0-dev   \
   libwxbase2.8-dev libwxbase2.8-dbg \
 
 
   libncurses5-dev \
 
   libncurses5-dev \
 
   zlib1g-dev gettext \
 
   zlib1g-dev gettext \
   libtiff4-dev libpngwriter-dev \
+
   libtiff5-dev libpnglite-dev \
   tcl8.4-dev tk8.4-dev \
+
   libcairo2 libcairo2-dev \
  libcairo libcairo-dev \
 
 
   sqlite3 libsqlite3-dev \
 
   sqlite3 libsqlite3-dev \
 
   libpq-dev \
 
   libpq-dev \
   libreadline5 libreadline5-dev libfreetype6-dev \
+
   libreadline6 libreadline6-dev libfreetype6-dev \
   txt2tags \
+
   libfftw3-3 libfftw3-dev \
  fftw3 fftw3-dev \
+
   libboost-thread-dev libboost-program-options-dev liblas-c-dev \
   libqt4-core libqt4-dbg libqt4-dev libqt4-gui libqt4-sql libqt4-qt3support \
+
   resolvconf \
  lsb-qt4 qt4-designer qt4-dev-tools qt4-doc qt4-qtconfig \
 
   libapt-pkg-perl resolvconf \
 
 
   libjasper-dev \
 
   libjasper-dev \
  ruby \
 
 
   subversion \
 
   subversion \
   ffmpeg ffmpeg2theora \
+
   libav-tools libavutil-dev ffmpeg2theora \
 
   libffmpegthumbnailer-dev \
 
   libffmpegthumbnailer-dev \
 
   libavcodec-dev \
 
   libavcodec-dev \
Line 58: Line 296:
 
   libavformat-dev libswscale-dev \
 
   libavformat-dev libswscale-dev \
 
   checkinstall \
 
   checkinstall \
   libglu1-mesa-dev libxmu-dev
+
   libglu1-mesa-dev libxmu-dev \
 +
  ghostscript
 +
</source>
 +
 
 +
The following dependencies concern [http://releases.ubuntu.com/trusty/ Ubuntu Trusty Tahr (14.04 LTS)]
 +
 
 +
<source lang="bash">
 +
# 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++ \
 +
  python python-dev \
 +
  python-dateutil libgsl0-dev python-numpy \
 +
  zlib1g-dev gettext \
 +
  libtiff-dev libpnglite-dev \
 +
  sqlite3 libsqlite3-dev \
 +
  libboost-thread-dev libboost-program-options-dev liblas-c-dev \
 +
  resolvconf \
 +
  subversion \
 +
  checkinstall \
 +
  cmake ccache \
 +
  python-opengl \
 +
  python-wxversion python-wxtools python-wxgtk2.8 \
 +
  wx2.8-headers wx-common libwxgtk2.8-dev libwxgtk2.8-dbg \
 +
  libwxbase2.8-dev  libwxbase2.8-dbg \
 +
  libncurses5-dev \
 +
  libcairo2 libcairo2-dev \
 +
  libpq-dev \
 +
  libreadline6 libreadline6-dev libfreetype6-dev \
 +
  libfftw3-3 libfftw3-dev \
 +
  libjasper-dev \
 +
  libav-tools libavutil-dev ffmpeg2theora \
 +
  libffmpegthumbnailer-dev \
 +
  libavcodec-dev \
 +
  libxmu-dev \
 +
  libavformat-dev libswscale-dev \
 +
  libglu1-mesa-dev libxmu-dev \
 +
  ghostscript</source>
 +
 
 +
 
 +
* See the additional packages bellow and in other sections and install them. Note that some of them are [http://grass.osgeo.org/grass70/source/REQUIREMENTS.html required], namely PROJ.4, GEOS and GDAL. If you don't have special requirements, it is usually enough just to install PROJ.4, GEOS and GDAL from repository (rather then compile them manually).
 +
 
 +
* for mysql support, <source lang="bash" enclose="none">libmysqlclient-dev</source> is required
 +
<source lang="bash">
 +
sudo apt-get install libmysqlclient-dev
 +
</source>
 +
 
 +
* for netcdf support, <source lang="bash" enclose="none">netcdf-bin</source> and <source lang="bash" enclose="none">libnetcdf-dev</source>  is required
 +
<source lang="bash">
 +
sudo apt-get install netcdf-bin libnetcdf-dev
 +
</source>
 +
 
 +
* for {{AddonCmd|i.spec.unmix}} Addon support, install LAPACK and BLAS:
 +
<source lang="bash">
 +
sudo apt-get install libatlas-dev libblas-dev liblapack-dev
 +
</source>
 +
 
 +
* create a directory as a simple user where all source code is going to be stored -- in this example, a directory named <source lang="bash" enclose="none">src</source> under <source lang="bash" enclose="none">/usr/local</source> is created <source lang="bash">
 +
sudo mkdir /usr/local/src
 +
</source>
 +
 
 +
* take over directories ownerships ('''replace''' below the terms ''userid'' and ''groupid'' with a real <source lang="bash" enclose="none">userid</source>): <source lang="bash">
 +
sudo chown userid:groupid /usr/local/src</source>
 +
 
 +
* similarly, grant <source lang="bash" enclose="none">rwx</source> (read-write-execute) permissions for our ''userid'' and ''groupid'' onto the <source lang="bash" enclose="none">src</source> directory: <source lang="bash">
 +
sudo chmod ug+rwx /usr/local/src</source>
 +
 
 +
=== Earlier Ubuntu versions ===
 +
 
 +
For [http://old-releases.ubuntu.com/releases/ earlier Ubuntu versions], '''watch out for dependency differences!''' Modify the dependency list given above as instructed below.
 +
 
 +
* for [http://releases.ubuntu.com/raring/ Ubuntu Raring Ringtail (13.04]), change the following dependencies:
 +
** <source lang="bash" enclose="none">libav-tools libavutil-dev --> ffmpeg</source>
 +
** <source lang="bash" enclose="none"> --> lesstif2-dev</source>
 +
 
 +
* for [http://releases.ubuntu.com/precise/ Ubuntu Precise Pangolin (12.04)], change the following dependencies:
 +
** <source lang="bash" enclose="none">libpnglite-dev --> libpngwriter-dev</source>
 +
** <source lang="bash" enclose="none">libtiff5-dev --> libtiff4-dev</source>
  
* for Ubuntu Maverick Meerkat (10.10) or later, change the following dependencies:
+
* for [http://old-releases.ubuntu.com/releases/maverick/ Ubuntu Maverick Meerkat (10.10)] or later, change the following dependencies:
libpngwriter-dev --> libpngwriter0-dev
+
** <source lang="bash" enclose="none">libpngwriter-dev --> libpngwriter0-dev</source>
libcairo-dev --> libcairo2-dev
+
** <source lang="bash" enclose="none">libcairo-dev --> libcairo2-dev</source>
fftw3 --> libfftw3-3
+
** <source lang="bash" enclose="none">fftw3 --> libfftw3-3</source>
fftw3-dev --> libfftw3-dev
+
** <source lang="bash" enclose="none">fftw3-dev --> libfftw3-dev</source>
 
   
 
   
(caveat: allegedly works for me - can someone please confirm? //Stefan )
+
* for [http://old-releases.ubuntu.com/releases/lucid/ Ubuntu Lucid Lynx (10.04)] or later, also install: <source lang="bash">sudo apt-get install libhdf4-alt-dev libhdf4-0-alt</source>
  
* for Ubuntu Lucid Lynx (10.04) or later, also install:
+
* for [http://old-releases.ubuntu.com/releases/ earlier Ubuntu versions], also install: <source lang="bash"> sudo apt-get install libhdf4g-dev libhdf4g-run</source>
sudo apt-get install libhdf4-alt-dev libhdf4-0-alt
 
  
* for earlier Ubuntu versions, also install:
+
== Using pre-compiled dev Packages for PROJ.4, GEOS and GDAL ==
sudo apt-get install libhdf4g-dev libhdf4g-run
 
  
* create a directory as a simple user where all source code is going to be stored (in this ''example'' a directory called '''src''' under '''/usr/local''' is used)
+
=== PROJ.4 ===
  
sudo mkdir /usr/local/src
+
Install the <source lang="bash" enclose="none">dev</source> package:
 +
 
 +
<source lang="bash">
 +
sudo apt-get install libproj-dev proj-data proj-bin
 +
</source>
 +
 
 +
* In the call to <source lang="bash" enclose="none">./configure</source> for [[#GRASS|GRASS]], replace <source lang="bash" enclose="none">--with-proj-share=/usr/local/share/proj/</source> by <source lang="bash" enclose="none">--with-proj-share=/usr/share/proj/</source>
 +
 
 +
=== GEOS ===
 +
 
 +
Install the <source lang="bash" enclose="none">dev</source> package:
 +
 
 +
<source lang="bash">
 +
# probably you also need to additionally install "libgeos-c1v5"
 +
sudo apt-get install libgeos-dev
 +
</source>
 +
 
 +
* In the call to <source lang="bash" enclose="none">./configure</source> for [[#GRASS|GRASS]], replace <source lang="bash" enclose="none">--with-geos=/usr/local/bin/geos-config</source> by <source lang="bash" enclose="none">--with-geos=/usr/bin/geos-config</source>
  
* grant rwx (read-write-execute) permissions for our userid/ groupid on the directory (replace words ''userid'' and ''groupid'' with real ''userid''):
+
=== GDAL ===
  
sudo chown ''userid'':''groupid'' /usr/local/src
+
Install the <source lang="bash" enclose="none">dev</source> package (possibly without support for datumgrid):
sudo chmod ug+rwx /usr/local/src
 
  
== PROJ4 ==
+
<source lang="bash">
 +
sudo apt-get install libgdal-dev
 +
</source>
  
Use either the packaged version (possibly without support for datumgrid), or compile from source:
+
For support of WMS in wxGUI install Python GDAL bindings and GDAL executables:
 +
<source lang="bash">
 +
sudo apt-get install python-gdal gdal-bin
 +
</source>
  
=== Packaged version ===
+
* Install also the required extra packages (note the message: <source lang="bash" enclose="none">The following extra packages will be installed:</source>)
 +
* Look out for packages to be removed by this operation -- this is most likely caused by incompatible package versions. Fix these problems in advance using commands like the following: <source lang="bash">
 +
sudo apt-get install <package>=<required.version></source>
  
sudo apt-get install libproj-dev
+
=== GRASS-GIS ===
  
* In the call to ''./configure'' for [[#GRASS|GRASS]], replace ''--with-proj-share=/usr/local/share/proj/'' by ''--with-proj-share=/usr/share/proj/''
+
[[Compile_and_Install_Ubuntu#GRASS_GIS|Jump to sub-section GRASS-GIS below]]
  
=== Compiled from source ===
+
== Using pre-compiled dev Packages for PROJ.4, GEOS and GDAL from GIS.lab PPA==
  
* within the directory ''/usr/local/src'' (create it if it does not exist) checkout proj from its Subversion repository:
+
Ivan Mincik has made all required packages available in his [https://launchpad.net/~imincik/+archive/ubuntu/gis PPA]:
svn co http://svn.osgeo.org/metacrs/proj/branches/4.7/proj/
 
  
* get [http://download.osgeo.org/proj/proj-datumgrid-1.5.zip '''proj-datumgrid-1.5.zip'''] from [http://trac.osgeo.org/proj proj' trac] and move it under '''proj/nad'''
+
<source lang="bash">
mv proj-datumgrid-1.5.tar.gz /usr/local/src/proj/nad
+
sudo add-apt-repository ppa:imincik/gis
cd /usr/local/src/proj/nad
+
sudo apt-get install libproj-dev libgdal-dev python-gdal libgeos-dev
 +
</source>
  
* decompress it
+
Now you can either also install GRASS GIS 7 from there or compile it yourself (see [[Compile_and_Install_Ubuntu#GRASS_GIS|Jump to sub-section GRASS-GIS below]])
unzip proj-datumgrid-1.5.zip
 
  
* go to proj directory
+
== Compile from source ==
cd /usr/local/src/proj
 
  
* if required, clean previous configuration & compilation
 
make distclean
 
  
* simple configure, compile and install
+
=== PROJ4 ===
./configure && make && sudo make install
 
  
* go to src directory
+
* within the directory <source lang="bash" enclose="none">/usr/local/src</source> (create it if it does not exist) checkout <source lang="bash" enclose="none">proj</source> from its Subversion repository: <source lang="bash">
cd /usr/local/src
+
svn co http://svn.osgeo.org/metacrs/proj/branches/4.8/proj/
 +
</source>
  
== GEOS ==
+
* get [http://download.osgeo.org/proj/proj-datumgrid-1.5.zip '''proj-datumgrid-1.5.zip'''] from [http://trac.osgeo.org/proj proj' trac] and move it under <source lang="bash" enclose="none">proj/nad</source>
 +
<ul><source lang="bash">
 +
wget http://download.osgeo.org/proj/proj-datumgrid-1.5.zip
 +
mv proj-datumgrid-1.5.zip /usr/local/src/proj/nad
 +
cd /usr/local/src/proj/nad
 +
</source>
 +
  </ul>
  
Use either the packaged version, or compile from source:
+
* decompress it <source lang="bash">
 +
unzip proj-datumgrid-1.5.zip
 +
</source>
  
=== Packaged version ===
+
* go back to the <source lang="bash" enclose="none">proj</source> directory <source lang="bash">
sudo apt-get install libgeos-dev
+
cd /usr/local/src/proj
 +
</source>
  
* In the call to ''./configure'' for [[#GRASS|GRASS]], replace ''--with-geos=/usr/local/bin/geos-config'' by ''--with-geos=/usr/bin/geos-config''
+
* if required, clean previous configuration & compilation <source lang="bash">
 +
make distclean
 +
</source>
  
=== Compiled from source ===
+
* simple configure, compile and install <source lang="bash">
 +
./configure  &&  make  &&  sudo make install
 +
</source>
 +
<ul> or <source lang="bash">
 +
./configure && make -j2  &&  sudo checkinstall
 +
</source>
 +
  </ul>
  
* download '''geos-3.2.2.tar.bz2''' from [http://trac.osgeo.org/geos/ http://trac.osgeo.org/geos], move to "source-code" directory and decompress
+
* ensure that <source lang="bash" enclose="none">/usr/local/lib</source> is added to <source lang="bash" enclose="none">/etc/ld.so.conf</source> and afterwards run <source lang="bash">
bunzip2 geos-3.2.2.tar.bz2
+
sudo ldconfig
tar xvf  geos-3.2.2.tar
+
</source>
  
* if required, clean previous configuration & compilation
+
* finally, go back to the parent directory simply by instructing<source lang="bash">
make distclean
+
cd ..
 +
</source>
  
* move to geos directory
+
=== GEOS ===
cd geos-3.2.2
 
  
* simple configure, compile and install
+
* download '''geos-3.4.2.tar.bz2''' from [http://trac.osgeo.org/geos/ http://trac.osgeo.org/geos] using <source lang="bash" enclose="none">wget</source> <source lang="bash">
./configure  &&  make  &&  sudo make install
+
wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2
 +
</source>
  
* Ensure that '''/usr/local/lib''' is added to '''/etc/ld.so.conf''' and run '''/sbin/ldconfig''' afterwards
+
* move to the "source-code" directory and decompress
sudo ldconfig
+
<ul><source lang="bash">
 +
cd /usr/local/src/
 +
bunzip2 geos-3.4.2.tar.bz2
 +
tar xvf  geos-3.4.2.tar
 +
</source>
 +
  </ul>
  
== GDAL ==
+
* if required, clean previous configuration & compilation  <source lang="bash">
 +
make distclean
 +
</source>
  
Use either the packaged version (possibly without support for datumgrid), or compile from source:
+
* move to geos directory  <source lang="bash">
 +
cd geos-3.4.2
 +
</source>
  
=== Packaged version ===
+
* simple configure, compile and install <source lang="bash">
 +
./configure  &&  make  &&  sudo make install
 +
</source>
 +
<ul> or <source lang="bash">
 +
./configure  && make -j2  &&  sudo checkinstall
 +
</source>
 +
  </ul>
  
sudo apt-get install libgdal-dev
+
* do not forget to execute <source lang="bash">
 +
sudo ldconfig
 +
</source>
  
* Install also the required extra packages (''The following extra packages will be installed:''). Look out for packages to be removed by this operation -- this is most likely caused by incompatible package version. Fix these problems in advance using commands like the following:
+
=== GDAL ===
  
sudo apt-get install <package>=<required.version>
+
'''Note''', GDAL must be compiled '''without''' GRASS support
  
=== Compiled from source ===
+
* download the current stable version <source lang="bash">
 +
svn co https://svn.osgeo.org/gdal/branches/1.11/gdal gdal_stable
 +
</source>
  
* GDAL must be compiled '''without''' GRASS support
+
* enter in the <source lang="bash" enclose="none">gdal_stable</source> directory <source lang="bash">
 +
cd /usr/local/src/gdal_stable
 +
</source>
  
* download current stable version
+
* optionally, update the source code <source lang="bash">
svn checkout https://svn.osgeo.org/gdal/branches/1.8/gdal gdal_stable
+
svn up
 +
</source>
  
* enter in directory '''gdal_stable'''
+
* if required, clean previous configurations/compilations <source lang="bash">
cd /usr/local/src/gdal_stable
+
make distclean
 +
</source>
  
* optionally, update the source code
+
* a simple configuration without any parameters will detect and support various installed libraries <source lang="bash">
svn up
+
./configure
 +
</source>
  
* if required, clean previous configurations/compilations
+
* skip to the ''compile and install'' step or check the following customised configuration example
  make distclean
+
<ul>
 +
<source lang="bash">
 +
CFLAGS="-g -Wall" LDFLAGS="-s" ./configure \
 +
--with-png=internal \
 +
--with-libtiff=internal \
 +
--with-geotiff=internal \
 +
--with-jpeg=internal \
 +
--with-gif=internal \
 +
--with-ecw=no \
 +
--with-expat=yes \
 +
--with-sqlite3=yes \
 +
--with-geos=yes \
 +
--with-python \
 +
--with-libz=internal \
 +
--with-netcdf \
 +
--with-threads=yes \
 +
--without-grass \
 +
--without-ogdi \
 +
--with-pg=/usr/bin/pg_config \
 +
--with-xerces=yes
 +
</source>
 +
  </ul>
  
* configure
+
* compile, install & ldconfig <source lang="bash">
CFLAGS="-g -Wall" LDFLAGS="-s" ./configure \
+
make -j2 && sudo make install && sudo ldconfig
--with-png=internal \
+
</source>
--with-libtiff=internal \
+
<ul> or <source lang="bash">
  --with-geotiff=internal \
+
make -j2 && sudo checkinstall && sudo ldconfig
--with-jpeg=internal \
+
</source>
  --with-gif=internal \
+
  </ul>
  --with-ecw=yes \
 
  --with-expat=yes \
 
--with-expat-inc=/usr/include/ \
 
--with-expat-lib=/usr/lib \
 
--with-sqlite3=yes \
 
  --with-geos=yes \
 
  --with-python \
 
  --with-libz=internal \
 
  --with-netcdf \
 
--with-sqlite \
 
--with-threads=yes \
 
--without-grass  \
 
--without-ogdi \
 
--with-pg=/usr/bin/pg_config \
 
--with-xerces=yes
 
  
* compile & install & ldconfig
+
=== GRASS GIS ===
make && sudo make install && sudo ldconfig
 
  
== GRASS ==
+
Note the differences between different GRASS version (SVN branches) in download and cofiguration. Note also the changes required if you installed some of the dependencies from packages (rather then compiled them yourself).
  
Before attempting to compile GRASS read section (C) titled ''(C) COMPILATION NOTES for 64bit platforms'' within the ''INSTALL'' file (which is located in the main directory of GRASS source code).
+
To fully understand the build process, read the <code>INSTALL</code> file, which is located in GRASS' source code root directory. For example, if you have problems related to 32bit versus 64bit, pay attention to section <code>(C)</code>, entitled <code>COMPILATION NOTES for 64bit platforms</code>.
  
 
''' Getting GRASS' source code '''
 
''' Getting GRASS' source code '''
  
* get current state of the 6.4.x release branch version (stable)
+
Select from one of the GRASS GIS versions and download (using SVN) the source code:
  svn checkout https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4 grass64_release
 
  
To download under development versions use:
+
* VERY OLD STABLE VERSION: current state of the 6.4.x release branch version (stable) <source lang="bash">
 +
svn co https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4 grass64_release
 +
</source>
  
* for GRASS 6.5 (reminder: * ''GRASS version 6.5 exists for development purposes and is not intended for end-users'')
+
* STABLE VERSION: current state of the 7.2.x release branch version (current stable) <source lang="bash">
svn checkout https://svn.osgeo.org/grass/grass/branches/develbranch_6 grass6_devel
+
svn co https://svn.osgeo.org/grass/grass/branches/releasebranch_7_2 grass72_release
 +
</source>
  
* for GRASS 7
+
* DEVELOPMENT VERSION: current state of the trunk (latest version of code where the development happens) <source lang="bash">
svn checkout https://svn.osgeo.org/grass/grass/trunk grass_trunk
+
svn co https://svn.osgeo.org/grass/grass/trunk grass7_trunk
 +
</source>
  
* for subsequent updates execute:
+
* for other versions see [http://trac.osgeo.org/grass/wiki/DownloadSource GRASS Trac wiki].
svn up
 
  
 
''' Configure, Compile and Install'''
 
''' Configure, Compile and Install'''
  
* if required, clean previous configuration & compilation
+
Enter the directory with the source code (downloaded by svn client), for example:
make distclean
+
 
 +
<source lang="bash">
 +
cd grass72_release
 +
</source>
 +
 
 +
* '''GRASS GIS 6 example configuration''' (which can/should be adjusted according to specific needs):
 +
<ul>
 +
<source lang="bash">
 +
CFLAGS="-O2 -Wall" LDFLAGS="-s" ./configure \
 +
--enable-largefile=yes \
 +
--with-nls \
 +
--with-cxx \
 +
--with-proj-share=/usr/local/share/proj/ \
 +
--with-geos=/usr/local/bin/geos-config \
 +
--with-readline \
 +
--with-python=yes \
 +
--with-wxwidgets \
 +
--with-cairo \
 +
--with-opengl-libs=/usr/include/GL \
 +
--with-motif \
 +
--with-tcltk-includes="/usr/include/tcl8.5" \
 +
--with-ffmpeg=yes --with-ffmpeg-includes="/usr/include/libavcodec /usr/include/libavformat /usr/include/libswscale /usr/include/libavutil" \
 +
--with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
 +
--with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \
 +
--with-sqlite=yes \
 +
--with-mysql=yes --with-mysql-includes="/usr/include/mysql" \
 +
--with-odbc=no
 +
</source>
 +
</ul>
 +
<ul>
 +
'''Note''', the above configuration uses the <code>Proj4</code> and <code>GEOS</code> packages compiled from the source. In the case that pre-compiled versions from the repository are required, remove the above corresponding lines to use the "defaults", i.e. <source lang="bash">
 +
--with-proj-share=/usr/share/proj \
 +
--with-geos=/usr/bin/geos-config \
 +
</source>
 +
  </ul>
 +
 
 +
* '''GRASS GIS 7 example configuration''' (which can/should be adjusted according to specific needs):
 +
<ul>
 +
<source lang="bash">
 +
CFLAGS="-O2 -Wall" LDFLAGS="-s" ./configure \
 +
--enable-largefile=yes \
 +
--with-nls \
 +
--with-cxx \
 +
--with-readline \
 +
--with-proj-share=/usr/local/share/proj/ \
 +
--with-geos=/usr/local/bin/geos-config \
 +
--with-wxwidgets \
 +
--with-cairo \
 +
--with-opengl-libs=/usr/include/GL \
 +
--with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
 +
--with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \
 +
--with-sqlite=yes \
 +
--with-mysql=yes --with-mysql-includes="/usr/include/mysql" \
 +
--with-odbc=no \
 +
--with-liblas=yes --with-liblas-config=/usr/bin/liblas-config
 +
</source>
 +
</ul>
 +
<ul>
 +
'''Note''', the above configuration uses the <code>Proj4</code> and <code>GEOS</code> packages compiled from the source. In the case that pre-compiled versions from the repository are required, remove the above corresponding lines to use the "defaults", i.e. (note the backslashe at the end of each line)
 +
<source lang="bash">
 +
--with-proj-share=/usr/share/proj \
 +
--with-geos=/usr/bin/geos-config \
 +
</source>
 +
'''Note 2''', if compiling with liblas, you will want liblas compiled with laszip support. liblas will look for laszip  includes in /usr/local/include/laszip by default. Creating the laszip directory in /usr/local/include and making a soft link.  ln -s /usr/local/include/lasz*.hpp /usr/local/include/laszip and ln -s /usr/local/include/lasunz*.hpp /usr/local/include/laszip should allow liblas to compile with laszip support
 +
  </ul>
 +
 
 +
* compile & install <source lang="bash">
 +
make -j2  &&  sudo make install  &&  sudo ldconfig
 +
</source>
 +
 
 +
<ul> or <source lang="bash">
 +
make -j2  &&  sudo checkinstall  &&  sudo ldconfig
 +
</source>
 +
  </ul>
 +
 
 +
For subsequent updates execute (not need for the first time):
 +
<source lang="bash">
 +
svn up
 +
make -j2 && sudo make install  &&  sudo ldconfig
 +
</source>
 +
 
 +
Sometimes, it is required to clean previous configuration and compilation:
 +
<source lang="bash">
 +
make distclean
 +
svn up
 +
./configure ... # (use the configure command above)
 +
make -j2 && sudo make install  &&  sudo ldconfig
 +
</source>
 +
 
 +
=== GDAL-GRASS-Plugin ===
 +
 
 +
* get the plugin from [http://download.osgeo.org/gdal OSGeo's Download Server]: "gdal-grass-X.Y.Z.tar.gz" using <source lang="bash" enclose="none">wget</source>
 +
<ul><source lang="bash">
 +
wget http://download.osgeo.org/gdal/gdal-grass-2.4.3.tar.gz
 +
tar xvzf gdal-grass-2.4.3.tar.gz
 +
cd gdal-grass-2.4.3
 +
</source></ul>
 +
 
 +
* create  <source lang="bash" enclose="none">/etc/ld.so.conf.d/grass.conf</source>  or add in  <source lang="bash" enclose="none">/etc/ld.so.conf</source> the GRASS library path:
 +
<ul><source lang="bash">
 +
# GRASS 7.8 library path (adapt as needed)
 +
/usr/local/src/releasebranch_7_8/lib
 +
 
 +
# GRASS 7 (development version) library path (adapt as needed)
 +
/usr/local/src/grass_master/lib
 +
</source></ul>
  
* example configuration (which can/should be adjusted according to specific needs):
+
* optionally, clean previous configurations/compilations<source lang="bash">
CFLAGS="-g" ./configure \
+
  make distclean</source>
--enable-debug \
 
--enable-64bit \
 
--with-libs=/usr/lib64 \
 
--with-cxx \
 
--with-readline \
 
--with-freetype=yes \
 
--with-freetype-includes="/usr/include/freetype2/" \
 
--enable-largefile=yes \
 
--with-proj-share=/usr/local/share/proj/ \
 
--with-geos=/usr/local/bin/geos-config \
 
--with-cairo \
 
--with-tcltk-includes="/usr/include/tcl8.4/" \
 
--with-wxwidgets \
 
--with-postgres=no \
 
--with-sqlite=yes \
 
--with-python=yes \
 
--with-opengl-libs=/usr/include/GL \
 
--with-ffmpeg=yes \
 
  --with-ffmpeg-includes="/usr/include/libavcodec /usr/include/libavformat /usr/include/libswscale"
 
  
* compile & install
+
* configure -- point to GRASS installation/binaries
  make -j2 && sudo make install && sudo ldconfig
+
<ul><source lang="bash"> ./configure \
 +
--prefix=/usr/local \
 +
--with-gdal=/usr/local/bin/gdal-config \
 +
--with-grass=/usr/local/grass-7.8.git/ \
 +
  --with-autoload="/usr/local/lib64/gdalplugins/" \
 +
--with-ld-shared="g++ -shared"</source></ul>
 +
<ul>
 +
* for GRASS 7.6, replace with <source lang="bash" enclose="none"> --with-grass=/usr/local/grass-7.6.3/</source>
 +
* for GRASS 7.x...
 +
</ul>
  
* alternatively, ''checkinstall'' can be used instead of ''make install''. A ''deb'' package will be created and installed (which can be easily uninstalled)
+
* compile & install using checkinstall<source lang="bash">
  make -j2 && sudo checkinstall && sudo ldconfig
+
  make -j2 && sudo checkinstall</source>
  
 
= Post compilation/installation control =
 
= Post compilation/installation control =
Line 263: Line 739:
 
= Removal of GRASS =
 
= Removal of GRASS =
  
To get rid of a GRASS binaries installation, delete
 
* /usr/local/grass-6.4.0svn (folder, binaries location)
 
* /usr/local/bin/grass64 (file)
 
* /usr/local/bin/gem64 (file)
 
* /home/username/.grassrc6 (file)
 
  
If needed, remove also the source code:
+
To get rid of a GRASS binaries installation, delete (update version numbers accordingly)
* /usr/local/src/grass_64svn (folder, source code location)
+
* <source lang="bash" enclose="none">/usr/local/grass-7.8.1.dev</source> (directory, binaries location)
 +
* <source lang="bash" enclose="none">/usr/local/bin/grass78</source> (file)
 +
* <source lang="bash" enclose="none">/home/username/.grassrc7</source> (file)
 +
 
 +
 
 +
If wanted, delete also the complete source code:
 +
* <source lang="bash" enclose="none">/usr/local/src/grass78_release</source> (directory, source code location)
 +
 
 +
 
 +
To remove <code>grass</code> (or any other package) which was installed by <source lang="bash" enclose="none">checkinstall</source>, use <source lang="bash" enclose="none">dpkg</source>, e.g.<source lang="bash">
 +
sudo dpkg -r grass78 # package name defined at installation is important</source>
 +
 
 +
= Packaging of GRASS =
 +
 
 +
* See https://salsa.debian.org/debian-gis-team/grass/tree/master/debian for directions on rolling your own packages.
 +
 
 +
For details about the auto-nightly-builds and after-market supplied packages from UbuntuGIS, please refer to the [[Ubuntu Packaging]] wiki page.
 +
 
 +
== See also ==
 +
 
 +
* Docker: https://grass.osgeo.org/download/software/docker-images/
 +
* [[Ubuntu Packaging]]
 +
* [[GRASS in Debian]]
 +
 
 +
= Archived Notes =
 +
 
 +
Notes that concern the configuration and compilation of GRASS GIS and its dependencies for older versions of Ubuntu-Linux.
 +
 
 +
== Ubuntu 7.10 64-bit ==
 +
 
 +
* Compiling latest GRASS source code on a 64-bit machine (with an ATI graphic card) under Ubuntu 7.10 64-bit with support for: 64-bit, SQLite, OpenGL, PYTHON, FFMPEG
 +
(Based on "Ubuntu 6.06 LTS - GRASS 6.1 Compilation Script" by David Finlayson)
 +
''Assuming it is the first time attempting to compile GRASS' source code & installing SVN, PROJ, GDAL/OGR''
 +
 
 +
'''Preparation'''
 +
sudo apt-get update && sudo apt-get upgrade
 +
 
 +
* install dependencies for compiling (in general) and dependencies for GRASS: PROJ, GDAL/OGR
 +
sudo apt-get install grass build-essential flex bison libncurses5-dev zlib1g-dev \
 +
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
 +
 
 +
* install SQLite
 +
sudo apt-get install sqlite3 libsqlite3-dev
 +
 
 +
* install SVN
 +
sudo apt-get install subversion
 +
 
 +
* create a directory as a simple user where source code(s) are going to be stored (in our example we use a directory called '''src''' under '''/usr/local''')
 +
 
 +
sudo mkdir /usr/local/src
 +
 
 +
* grant rwx (read-write-execute) permissions for our userid/ groupid on the directory (replace words userid and groupid with real userid):
 +
sudo chown ''userid'':''groupid'' /usr/local/src
 +
 
 +
sudo chmod ug+rwx /usr/local/src
 +
 
 +
* download latest source code from GRASS SVN repository in a directory on the system (e.g. /usr/local/src)
 +
svn checkout https://svn.osgeo.org/grass/grass/trunk grass_trunk
 +
 
 +
* Above command places GRASS' source code in '''/usr/local/src/grass_trunk'''. In case of a subsequent update use the command: '''svn up''' from within the grass_trunk directory
 +
 
 +
----
 +
'''Before''' attempting to compile GRASS, READ section (C) in the '''INSTALL''' file located in the main directory of GRASS source code entitled:
 +
'''(C) COMPILATION NOTES for 64bit platforms'''
 +
----
 +
 
 +
* installing FFTW3 if not already on system
 +
sudo apt-get install fftw3 fftw3-dev
 +
 
 +
'''FFMPEG'''
 +
 
 +
Note: Back in Ubuntu 7.10, installing ffmpeg through the repositories wouldn't work with grass. The following steps were successfully used.
 +
 
 +
* install FFMPEG (information taken from: http://stream0.org/2008/01/install-ffmpeg-on-ubuntu-gutsy.html)
 +
* download source code with svn
 +
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
 +
 
 +
* install dependencies
 +
sudo apt-get install liblame-dev libfaad2-dev libfaac-dev libxvidcore4-dev \
 +
      liba52-0.7.4 liba52-0.7.4-dev libx264-dev libdts-dev checkinstall \
 +
      build-essential subversion
 +
 
 +
* guide to ffmpeg directory
 +
cd ffmpeg
 +
 
 +
if necessary: '''make distclean''' before configuration (look at notes below)
 +
 
 +
* configuration ('''note:''' the configuration parameter "'''--enable-pp'''" does not work anymore)
 +
# configure FFMPEG
 +
./configure --enable-gpl --enable-libvorbis --enable-libtheora \
 +
            --enable-liba52 --enable-libdc1394 --enable-libgsm \
 +
            --enable-libmp3lame --enable-libfaad --enable-libfaac \
 +
            --enable-libxvid --enable-libx264 \
 +
            --enable-shared
 +
 
 +
* compilation
 +
make
 +
 
 +
* installation on /usr/local/bin -- important to remember when configuring GRASS' source code for compilation
 +
sudo checkinstall
 +
 
 +
'''Go for GRASS!'''
 +
* in our example we used the /usr/local/src directory to store GRASS' source code, so:
 +
cd /usr/local/src/grass_trunk
 +
 
 +
* configuration
 +
  CFLAGS="-g -Wall" ./configure --enable-64bit \
 +
        --with-libs=/usr/lib64 --with-cxx --with-freetype=yes \
 +
        --with-postgres=no --with-sqlite=yes --enable-largefile=yes \
 +
        --with-tcltk-includes=/usr/include/tcl8.4 \
 +
        --with-freetype-includes=/usr/include/freetype2 \
 +
        --with-opengl-libs=/usr/include/GL --with-readline \
 +
        --with-python=yes --with-ffmpeg=yes \
 +
        --with-ffmpeg-includes=/usr/local/include/ffmpeg
 +
 
 +
*if OpenGL fails then maybe it is necessary to link '''glxATI.h''' with '''glx.h''' and re-run the configuration
 +
 
 +
cd /usr/include/GL
 +
 
 +
sudo ln glxATI.h glx.h
 +
 
 +
* compilation
 +
make
 +
 
 +
* compilation is expected to end with a statement similar to the following:
 +
 
 +
Started compilation: Wed Feb 27 00:24:36 CET 2008
 +
--
 +
Errors in:
 +
No errors detected.
 +
 
 +
* installation
 +
sudo checkinstall
 +
 
 +
* launch 64-bit GRASS.6.4.svn
 +
grass64
 +
 
 +
'''Notes'''
 +
* in case of errors in future compilation attempts, remember to remove program binaries with
 +
make clean
 +
* and the files created with the "configuration" from previous compilations with
 +
make distclean
 +
 
 +
== Ubuntu 6.06, 7.10 ==
 +
 
 +
* [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
 +
** 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
 +
** Think twice before using this script. Some users experienced problems such as disabled XGL etc.
 +
* [[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.
  
To remove grass (or any other package) installed by using ''checkinstall'', e.g.
 
sudo dpkg -r grass64 # package name defined at installation is important
 
  
 +
[[Category: Compilation]]
 
[[Category: Installation]]
 
[[Category: Installation]]
 +
[[Category: Ubuntu]]
 +
[[Category: FAQ]]

Latest revision as of 09:02, 23 December 2020

Very Important notes

  • Pre-compiled packages and backports are available from UbuntuGIS via their ppa.launchpad repositories. This is by far the simplest and fastest solution. Please prefer it over the manual way of compiling source code yourself as described below.
    • Daily ready to installl GRASS GIS builds of the 7.x release branch and trunk are available from ppa:grass/grass-devel
      sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
      
      sudo add-apt-repository ppa:grass/grass-devel
      
    • Latest version of GRASS 7.x is available from ppa:grass/grass-stable
      sudo add-apt-repository ppa:ubuntugis/ppa
      
      sudo add-apt-repository ppa:grass/grass-stable
      
    sudo apt-get update
    
    sudo apt-get install grass76
    

Quick instructions

These instructions should work fine on Ubuntu distributions prior to release 20.04:

1. Install some dependencies (PROJ, GEOS, GDAL libraries) and the compiler tools
(note: for GRASS GIS 7.8+ you need Python 3!)

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

# install PROJ
sudo apt-get install libproj-dev proj-data proj-bin unzip -y

# optionally, install (selected) datum grid files
# Future: The proj-datumgrid packages have been deprecated with PROJ 7.0.0+
cd /tmp
wget -c https://download.osgeo.org/proj/proj-datumgrid-world-latest.zip
wget -c https://download.osgeo.org/proj/proj-datumgrid-oceania-latest.zip
wget -c https://download.osgeo.org/proj/proj-datumgrid-north-america-latest.zip
wget -c https://download.osgeo.org/proj/proj-datumgrid-europe-latest.zip
# unpack and remove zip files
cd /usr/share/proj/
for datumfile in $(ls /tmp/proj-datumgrid-*-latest.zip) ; do
sudo unzip $datumfile && rm -f $datumfile
done

# optionally, install (selected) datum grid files
sudo apt-get install proj-data

# install GEOS
sudo apt-get install libgeos-dev -y

# install GDAL
sudo apt-get install libgdal-dev python3-gdal gdal-bin -y

# install PDAL (optional)
sudo apt-get install libpdal-dev pdal libpdal-plugin-python -y

# 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 1

Install compiler stuff and further dependencies. Note: this is a single command, please copy-paste it entirely into the terminal:

For Ubuntu 19.04 (see below for Ubuntu 20.04)

sudo apt-get install \
  build-essential \
  flex make bison gcc libgcc1 g++ ccache \
  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-dev \
  libwxbase3.0-dev   \
  libncurses5-dev \
  libbz2-dev \
  zlib1g-dev gettext \
  libtiff5-dev libpnglite-dev \
  libcairo2 libcairo2-dev \
  sqlite3 libsqlite3-dev \
  libpq-dev \
  libreadline6-dev libfreetype6-dev \
  libfftw3-3 libfftw3-dev \
  libboost-thread-dev libboost-program-options-dev liblas-c-dev \
  subversion libzstd-dev \
  checkinstall \
  libglu1-mesa-dev libxmu-dev \
  ghostscript wget -y

This are optional video codec libraries for NVIZ video output for Ubuntu 19.04:

sudo apt-get install \
  libav-tools libavutil-dev ffmpeg2theora \
  libffmpegthumbnailer-dev \
  libavcodec-dev \
  libxmu-dev \
  libavformat-dev libswscale-dev

For Ubuntu 20.04:

 sudo apt-get install \
  build-essential \
  flex make bison gcc libgcc1 g++ ccache \
  python3 python3-dev \
  python3-opengl python3-wxgtk4.0 \
  python3-dateutil libgsl-dev python3-numpy \
  wx3.0-headers wx-common libwxgtk3.0-gtk3-dev \
  libwxbase3.0-dev   \
  libncurses5-dev \
  libbz2-dev \
  zlib1g-dev gettext \
  libtiff5-dev libpnglite-dev \
  libcairo2 libcairo2-dev \
  sqlite3 libsqlite3-dev \
  libpq-dev \
  libreadline6-dev libfreetype6-dev \
  libfftw3-3 libfftw3-dev \
  libboost-thread-dev libboost-program-options-dev  libpdal-dev\
  subversion libzstd-dev \
  checkinstall \
  libglu1-mesa-dev libxmu-dev \
  ghostscript wget -y

For NVIZ on Ubuntu 20.04:

sudo apt-get install \
  ffmpeg libavutil-dev ffmpeg2theora \
  libffmpegthumbnailer-dev \
  libavcodec-dev \
  libxmu-dev \
  libavformat-dev libswscale-dev

Now we have all "ingredients" readily installed on our system.

Source code download:

There a two ways of getting the source code: either use a) the weekly snapshot (cannot be updated, or b) the source code from the GitHub repository (you can update your local copy easily in future):

a) Download of the weekly source code snapshot (not recommended):

# download latest GRASS GIS 7.x stable release source code:
mkdir $HOME/src/
cd  $HOME/src/
wget https://grass.osgeo.org/grass78/source/snapshot/grass-7.8.git_src_snapshot_latest.tar.gz

# Unpack source code package and remove tarball archive:
tar xvfz grass-7.8.git_src_snapshot_latest.tar.gz
rm -f grass-7.8.git_src_snapshot_latest.tar.gz 

# rename source code directory (yes, with the questionmarks!)
mv grass-7.8.git_src_snapshot_20??_??_?? grass-7.8.latest
cd grass-7.8.latest/

b) Download of the current development version from GitHub (adopt the path below accordingly)

git clone https://github.com/OSGeo/grass.git grass-7.8.latest.git
cd grass-7.8.latest.git/
git checkout releasebranch_7_8

Now we can compile the source code in order to generate the GRASS GIS binaries:

# "configure" source code for local machine (checks for CPU type etc):
MYCFLAGS='-O2 -fPIC -fno-common -fexceptions -std=gnu99 -fstack-protector -m64'
#MYCXXFLAGS=''
MYLDFLAGS='-Wl,--no-undefined -Wl,-z,now'

LDFLAGS="$MYLDFLAGS" CFLAGS="$MYCFLAGS" CXXFLAGS="$MYCXXFLAGS" ./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-liblas \
  --with-pdal \
  --with-cairo --with-cairo-ldflags=-lfontconfig \
  --with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
  --with-wxwidgets \
  --with-fftw \
  --with-motif \
  --with-opengl-libs=/usr/include/GL \
  --with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \
  --without-netcdf \
  --without-mysql \
  --without-odbc \
  --without-openmp \
  --without-ffmpeg

For Ubuntu 20.04 remove --with-liblas :

# "configure" source code for local machine (checks for CPU type etc):
MYCFLAGS='-O2 -fPIC -fno-common -fexceptions -std=gnu99 -fstack-protector -m64'
#MYCXXFLAGS=''
MYLDFLAGS='-Wl,--no-undefined -Wl,-z,now'

LDFLAGS="$MYLDFLAGS" CFLAGS="$MYCFLAGS" CXXFLAGS="$MYCXXFLAGS" ./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-pdal \
  --with-cairo --with-cairo-ldflags=-lfontconfig \
  --with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
  --with-wxwidgets \
  --with-fftw \
  --with-motif \
  --with-opengl-libs=/usr/include/GL \
  --with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \
  --without-netcdf \
  --without-mysql \
  --without-odbc \
  --without-openmp \
  --without-ffmpeg


Now compile source code (takes some time as it generates binary code from the source code):

# note: the more CPUs you have, the higher the -j number may be set to
# here: build using 4 CPU cores
make -j4

Install resulting GRASS GIS 7 binaries into /usr/local/:

sudo make install

Start GRASS GIS in the terminal:

grass78

Done & enjoy!

Hints

  • Usually, the installation of compiled code is done by using the make tool. Alternatively, this can be done by using the checkinstall tool (i.e., sudo checkinstall instead of sudo make install) which eases off removal of packages. If checkinstall fails to deliver, please note some related bugs: 78455 and 599163. Useful information on using checkinstall: Compiling things on Ubuntu the Easy Way.
  • In multi-core processors, the compilation performance can be boosted by using -j switches (e.g. make -j2 or make -j3 or even make -j4) which specify the number of jobs (commands) to run simultaneously.

Dependencies

Current stable Ubuntu version

First, update the system from the repositories
sudo apt-get update && sudo apt-get upgrade

Then, install SQLite, SVN and dependencies for compiling PROJ, GEOS, GDAL/OGR, GRASS, GDAL-GRASS-PLUGIN (some additional packages may be required in this case); the following action will also install various dependencies (listed in the command line as The following extra packages will be installed:...):

The following dependencies concern Ubuntu Xenial Xerus (16.04 LTS)

# 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 \
  python python-dev \
  python-opengl \
  python-wxversion python-wxtools python-wxgtk3.0 \
  python-dateutil libgsl-dev python-numpy \
  wx3.0-headers wx-common libwxgtk3.0-dev \
  libwxbase3.0-dev   \
  libncurses5-dev \
  zlib1g-dev gettext \
  libtiff5-dev libpnglite-dev \
  libcairo2 libcairo2-dev \
  sqlite3 libsqlite3-dev \
  libpq-dev \
  libreadline6 libreadline6-dev libfreetype6-dev \
  libfftw3-3 libfftw3-dev \
  libboost-thread-dev libboost-program-options-dev liblas-c-dev \
  resolvconf \
  libjasper-dev \
  subversion \
  libav-tools libavutil-dev ffmpeg2theora \
  libffmpegthumbnailer-dev \
  libavcodec-dev \
  libxmu-dev \
  libavformat-dev libswscale-dev \
  checkinstall \
  libglu1-mesa-dev libxmu-dev \
  ghostscript

The following dependencies concern Ubuntu Trusty Tahr (14.04 LTS)

# 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++ \
  python python-dev \
  python-dateutil libgsl0-dev python-numpy \
  zlib1g-dev gettext \
  libtiff-dev libpnglite-dev \
  sqlite3 libsqlite3-dev \
  libboost-thread-dev libboost-program-options-dev liblas-c-dev \
  resolvconf \
  subversion \
  checkinstall \
  cmake ccache \
  python-opengl \
  python-wxversion python-wxtools python-wxgtk2.8 \
  wx2.8-headers wx-common libwxgtk2.8-dev libwxgtk2.8-dbg \
  libwxbase2.8-dev  libwxbase2.8-dbg \
  libncurses5-dev \
  libcairo2 libcairo2-dev \
  libpq-dev \
  libreadline6 libreadline6-dev libfreetype6-dev \
  libfftw3-3 libfftw3-dev \
  libjasper-dev \
  libav-tools libavutil-dev ffmpeg2theora \
  libffmpegthumbnailer-dev \
  libavcodec-dev \
  libxmu-dev \
  libavformat-dev libswscale-dev \
  libglu1-mesa-dev libxmu-dev \
  ghostscript


  • See the additional packages bellow and in other sections and install them. Note that some of them are required, namely PROJ.4, GEOS and GDAL. If you don't have special requirements, it is usually enough just to install PROJ.4, GEOS and GDAL from repository (rather then compile them manually).
  • for mysql support, libmysqlclient-dev is required
sudo apt-get install libmysqlclient-dev
  • for netcdf support, netcdf-bin and libnetcdf-dev is required
sudo apt-get install netcdf-bin libnetcdf-dev
sudo apt-get install libatlas-dev libblas-dev liblapack-dev
  • create a directory as a simple user where all source code is going to be stored -- in this example, a directory named src under /usr/local is created
    sudo mkdir /usr/local/src
    
  • take over directories ownerships (replace below the terms userid and groupid with a real userid):
    sudo chown userid:groupid /usr/local/src
    
  • similarly, grant rwx (read-write-execute) permissions for our userid and groupid onto the src directory:
    sudo chmod ug+rwx /usr/local/src
    

Earlier Ubuntu versions

For earlier Ubuntu versions, watch out for dependency differences! Modify the dependency list given above as instructed below.

  • for Ubuntu Maverick Meerkat (10.10) or later, change the following dependencies:
    • libpngwriter-dev --> libpngwriter0-dev
    • libcairo-dev --> libcairo2-dev
    • fftw3 --> libfftw3-3
    • fftw3-dev --> libfftw3-dev

Using pre-compiled dev Packages for PROJ.4, GEOS and GDAL

PROJ.4

Install the dev package:

sudo apt-get install libproj-dev proj-data proj-bin
  • In the call to ./configure for GRASS, replace --with-proj-share=/usr/local/share/proj/ by --with-proj-share=/usr/share/proj/

GEOS

Install the dev package:

# probably you also need to additionally install "libgeos-c1v5"
sudo apt-get install libgeos-dev
  • In the call to ./configure for GRASS, replace --with-geos=/usr/local/bin/geos-config by --with-geos=/usr/bin/geos-config

GDAL

Install the dev package (possibly without support for datumgrid):

sudo apt-get install libgdal-dev

For support of WMS in wxGUI install Python GDAL bindings and GDAL executables:

sudo apt-get install python-gdal gdal-bin
  • Install also the required extra packages (note the message: The following extra packages will be installed:)
  • Look out for packages to be removed by this operation -- this is most likely caused by incompatible package versions. Fix these problems in advance using commands like the following:
    sudo apt-get install <package>=<required.version>
    

GRASS-GIS

Jump to sub-section GRASS-GIS below

Using pre-compiled dev Packages for PROJ.4, GEOS and GDAL from GIS.lab PPA

Ivan Mincik has made all required packages available in his PPA:

sudo add-apt-repository ppa:imincik/gis
sudo apt-get install libproj-dev libgdal-dev python-gdal libgeos-dev

Now you can either also install GRASS GIS 7 from there or compile it yourself (see Jump to sub-section GRASS-GIS below)

Compile from source

PROJ4

  • within the directory /usr/local/src (create it if it does not exist) checkout proj from its Subversion repository:
    svn co http://svn.osgeo.org/metacrs/proj/branches/4.8/proj/
    
    wget http://download.osgeo.org/proj/proj-datumgrid-1.5.zip
    mv proj-datumgrid-1.5.zip /usr/local/src/proj/nad
    cd /usr/local/src/proj/nad
    
  • decompress it
    unzip proj-datumgrid-1.5.zip
    
  • go back to the proj directory
    cd /usr/local/src/proj
    
  • if required, clean previous configuration & compilation
    make distclean
    
  • simple configure, compile and install
    ./configure  &&  make  &&  sudo make install
    
    or
    ./configure && make -j2  &&  sudo checkinstall
    
  • ensure that /usr/local/lib is added to /etc/ld.so.conf and afterwards run
    sudo ldconfig
    
  • finally, go back to the parent directory simply by instructing
    cd ..
    

GEOS

  • move to the "source-code" directory and decompress
    cd /usr/local/src/
    bunzip2 geos-3.4.2.tar.bz2
    tar xvf  geos-3.4.2.tar
    
  • if required, clean previous configuration & compilation
    make distclean
    
  • move to geos directory
    cd geos-3.4.2
    
  • simple configure, compile and install
    ./configure  &&  make  &&  sudo make install
    
    or
    ./configure  && make -j2  &&  sudo checkinstall
    
  • do not forget to execute
    sudo ldconfig
    

GDAL

Note, GDAL must be compiled without GRASS support

  • download the current stable version
    svn co https://svn.osgeo.org/gdal/branches/1.11/gdal gdal_stable
    
  • enter in the gdal_stable directory
    cd /usr/local/src/gdal_stable
    
  • optionally, update the source code
    svn up
    
  • if required, clean previous configurations/compilations
    make distclean
    
  • a simple configuration without any parameters will detect and support various installed libraries
    ./configure
    
  • skip to the compile and install step or check the following customised configuration example
    CFLAGS="-g -Wall" LDFLAGS="-s" ./configure \
    --with-png=internal \
    --with-libtiff=internal \
    --with-geotiff=internal \
    --with-jpeg=internal \
    --with-gif=internal \
    --with-ecw=no \
    --with-expat=yes \
    --with-sqlite3=yes \
    --with-geos=yes \
    --with-python \
    --with-libz=internal \
    --with-netcdf \
    --with-threads=yes \
    --without-grass  \
    --without-ogdi \
    --with-pg=/usr/bin/pg_config \
    --with-xerces=yes
    
  • compile, install & ldconfig
    make -j2  &&  sudo make install  &&  sudo ldconfig
    
    or
    make -j2  &&  sudo checkinstall  &&  sudo ldconfig
    

GRASS GIS

Note the differences between different GRASS version (SVN branches) in download and cofiguration. Note also the changes required if you installed some of the dependencies from packages (rather then compiled them yourself).

To fully understand the build process, read the INSTALL file, which is located in GRASS' source code root directory. For example, if you have problems related to 32bit versus 64bit, pay attention to section (C), entitled COMPILATION NOTES for 64bit platforms.

Getting GRASS' source code

Select from one of the GRASS GIS versions and download (using SVN) the source code:

  • VERY OLD STABLE VERSION: current state of the 6.4.x release branch version (stable)
    svn co https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4 grass64_release
    
  • STABLE VERSION: current state of the 7.2.x release branch version (current stable)
    svn co https://svn.osgeo.org/grass/grass/branches/releasebranch_7_2 grass72_release
    
  • DEVELOPMENT VERSION: current state of the trunk (latest version of code where the development happens)
    svn co https://svn.osgeo.org/grass/grass/trunk grass7_trunk
    

Configure, Compile and Install

Enter the directory with the source code (downloaded by svn client), for example:

cd grass72_release
  • GRASS GIS 6 example configuration (which can/should be adjusted according to specific needs):
    CFLAGS="-O2 -Wall" LDFLAGS="-s" ./configure \
    --enable-largefile=yes \
    --with-nls \
    --with-cxx \
    --with-proj-share=/usr/local/share/proj/ \
    --with-geos=/usr/local/bin/geos-config \
    --with-readline \
    --with-python=yes \
    --with-wxwidgets \
    --with-cairo \
    --with-opengl-libs=/usr/include/GL \
    --with-motif \
    --with-tcltk-includes="/usr/include/tcl8.5" \
    --with-ffmpeg=yes --with-ffmpeg-includes="/usr/include/libavcodec /usr/include/libavformat /usr/include/libswscale /usr/include/libavutil" \
    --with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
    --with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \
    --with-sqlite=yes \
    --with-mysql=yes --with-mysql-includes="/usr/include/mysql" \
    --with-odbc=no
    
    Note, the above configuration uses the Proj4 and GEOS packages compiled from the source. In the case that pre-compiled versions from the repository are required, remove the above corresponding lines to use the "defaults", i.e.
    --with-proj-share=/usr/share/proj \
    --with-geos=/usr/bin/geos-config \
    
  • GRASS GIS 7 example configuration (which can/should be adjusted according to specific needs):
    CFLAGS="-O2 -Wall" LDFLAGS="-s" ./configure \
    --enable-largefile=yes \
    --with-nls \
    --with-cxx \
    --with-readline \
    --with-proj-share=/usr/local/share/proj/ \
    --with-geos=/usr/local/bin/geos-config \
    --with-wxwidgets \
    --with-cairo \
    --with-opengl-libs=/usr/include/GL \
    --with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
    --with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \
    --with-sqlite=yes \
    --with-mysql=yes --with-mysql-includes="/usr/include/mysql" \
    --with-odbc=no \
    --with-liblas=yes --with-liblas-config=/usr/bin/liblas-config
    
    Note, the above configuration uses the Proj4 and GEOS packages compiled from the source. In the case that pre-compiled versions from the repository are required, remove the above corresponding lines to use the "defaults", i.e. (note the backslashe at the end of each line)
    --with-proj-share=/usr/share/proj \
    --with-geos=/usr/bin/geos-config \
    

    Note 2, if compiling with liblas, you will want liblas compiled with laszip support. liblas will look for laszip includes in /usr/local/include/laszip by default. Creating the laszip directory in /usr/local/include and making a soft link. ln -s /usr/local/include/lasz*.hpp /usr/local/include/laszip and ln -s /usr/local/include/lasunz*.hpp /usr/local/include/laszip should allow liblas to compile with laszip support

  • compile & install
    make -j2  &&  sudo make install  &&  sudo ldconfig
    
    or
    make -j2  &&  sudo checkinstall  &&  sudo ldconfig
    

For subsequent updates execute (not need for the first time):

svn up
make -j2 && sudo make install  &&  sudo ldconfig

Sometimes, it is required to clean previous configuration and compilation:

make distclean
svn up
./configure ... # (use the configure command above)
make -j2 && sudo make install  &&  sudo ldconfig

GDAL-GRASS-Plugin

    wget http://download.osgeo.org/gdal/gdal-grass-2.4.3.tar.gz
    tar xvzf gdal-grass-2.4.3.tar.gz
    cd gdal-grass-2.4.3
    
  • create /etc/ld.so.conf.d/grass.conf or add in /etc/ld.so.conf the GRASS library path:
    # GRASS 7.8 library path (adapt as needed)
    /usr/local/src/releasebranch_7_8/lib
    
    # GRASS 7 (development version) library path (adapt as needed)
    /usr/local/src/grass_master/lib
    
  • optionally, clean previous configurations/compilations
     make distclean
    
  • configure -- point to GRASS installation/binaries
     ./configure \
     --prefix=/usr/local \
     --with-gdal=/usr/local/bin/gdal-config \
     --with-grass=/usr/local/grass-7.8.git/ \
     --with-autoload="/usr/local/lib64/gdalplugins/" \
     --with-ld-shared="g++ -shared"
    
    • for GRASS 7.6, replace with --with-grass=/usr/local/grass-7.6.3/
    • for GRASS 7.x...
  • compile & install using checkinstall
     make -j2  &&  sudo checkinstall
    

Post compilation/installation control

  • in case of errors in future compilation attempts, remember to remove program binaries and files created with the "configuration" from previous compilations with
make distclean
  • another common mistake is compiling a module against some GRASS version and then try to run it through another GRASS version. The solution is to recompile the affected module or, in case there are multiple GRASS installations, set up properly LD_LIBRARY_PATH paths.


Removal of GRASS

To get rid of a GRASS binaries installation, delete (update version numbers accordingly)

  • /usr/local/grass-7.8.1.dev (directory, binaries location)
  • /usr/local/bin/grass78 (file)
  • /home/username/.grassrc7 (file)


If wanted, delete also the complete source code:

  • /usr/local/src/grass78_release (directory, source code location)


To remove grass (or any other package) which was installed by checkinstall, use dpkg, e.g.
sudo dpkg -r grass78 # package name defined at installation is important

Packaging of GRASS

For details about the auto-nightly-builds and after-market supplied packages from UbuntuGIS, please refer to the Ubuntu Packaging wiki page.

See also

Archived Notes

Notes that concern the configuration and compilation of GRASS GIS and its dependencies for older versions of Ubuntu-Linux.

Ubuntu 7.10 64-bit

  • Compiling latest GRASS source code on a 64-bit machine (with an ATI graphic card) under Ubuntu 7.10 64-bit with support for: 64-bit, SQLite, OpenGL, PYTHON, FFMPEG

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

Preparation

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

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


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

FFMPEG

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

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

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

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

Go for GRASS!

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

Notes

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

Ubuntu 6.06, 7.10

  • makegrass.sh is script designed to automate most of the download, configuration and compilation of GRASS 6.x-CVS
    • it is advised use checkinstall (sudo apt-get install checkinstall) instead of make install to keep track of installed software
    • Think twice before using this script. Some users experienced problems such as disabled XGL etc.
  • Here is another of these scripts, it's homemade so probably you'll find the above more useful for production sites.