Compile and Install Ubuntu: Difference between revisions
(→Quick instructions: since it is easily overlooked, always install python3-wxgtk4.0) |
(remove liblas, subversion; add git) |
||
(26 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
<div class="boilerplate metadata" id="attention" style="-moz-border-radius:30px; border: 1px double #35824B; margin-bottom: 1.5em; padding: 1em; background-color: #f9f9f9;"> | <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> </p><span style="color:#333333">'''The following instructions describe the compilation and installation of | <p style="font-size: 150%; text-align: left;"><span style="color:#35824B">'''Attention'''</span> </p><span style="color:#333333">'''The following instructions describe the compilation and installation of GRASS GIS 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> | </div> | ||
== | == Quick instructions == | ||
These instructions should work fine on Ubuntu distributions: | |||
== | === Install geospatial dependencies === | ||
1. Install some dependencies (PROJ, GEOS, GDAL libraries) and the compiler tools <br /> | |||
(note: you need Python 3) | |||
<source lang="bash"> | <source lang="bash"> | ||
# be sure to have an updated system | # be sure to have an updated system | ||
sudo apt | sudo apt update && sudo apt upgrade -y | ||
# install PROJ | # install PROJ | ||
sudo apt | sudo apt install libproj-dev proj-data proj-bin unzip -y | ||
</source> | |||
<source lang="bash"> | |||
# optionally, install (selected) datum grid files | |||
sudo apt-get install proj-data | |||
# install GEOS | # install GEOS | ||
sudo apt | sudo apt install libgeos-dev -y | ||
# install GDAL | # install GDAL | ||
sudo apt | sudo apt install libgdal-dev python3-gdal gdal-bin -y | ||
# install PDAL (optional) | # install PDAL (optional) | ||
sudo apt | sudo apt install libpdal-dev pdal -y | ||
# Python3 precedence over Python2 (which is end-of-life since 2019, so it should be the default anyway) | |||
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: | |||
=== Install further compilation dependencies (Ubuntu 22.04) === | |||
sudo apt-get install \ | For Ubuntu 22.04: | ||
<source lang="bash"> | |||
sudo apt-get install \ | |||
build-essential \ | build-essential \ | ||
flex make bison gcc libgcc1 g++ | flex make bison gcc libgcc1 g++ ccache \ | ||
python3 python3-dev python3-pip \ | |||
python3-opengl python3-wxgtk4.0 \ | |||
python3-dateutil libgsl-dev python3-numpy \ | |||
wx3.0-headers wx-common libwxgtk3.0-gtk3-dev \ | |||
wx3.0-headers wx-common libwxgtk3.0-dev \ | |||
libwxbase3.0-dev \ | libwxbase3.0-dev \ | ||
libncurses5-dev \ | libncurses5-dev \ | ||
libbz2-dev \ | |||
zlib1g-dev gettext \ | zlib1g-dev gettext \ | ||
libtiff5-dev libpnglite-dev \ | libtiff5-dev libpnglite-dev \ | ||
libcairo2 libcairo2-dev \ | libcairo2 libcairo2-dev \ | ||
sqlite3 libsqlite3-dev \ | sqlite3 libsqlite3-dev \ | ||
libpq-dev \ | libpdal-dev libpq-dev \ | ||
libreadline-dev libfreetype6-dev \ | |||
libfftw3-3 libfftw3-dev \ | libfftw3-3 libfftw3-dev \ | ||
libboost-thread-dev libboost-program-options | libboost-thread-dev libboost-program-options-dev \ | ||
git libzstd-dev \ | |||
checkinstall \ | checkinstall \ | ||
libglu1-mesa-dev libxmu-dev \ | libglu1-mesa-dev libxmu-dev \ | ||
Line 63: | Line 68: | ||
</source> | </source> | ||
For NVIZ on Ubuntu: | |||
<source lang="bash"> | <source lang="bash"> | ||
sudo apt-get install \ | sudo apt-get install \ | ||
ffmpeg libavutil-dev ffmpeg2theora \ | |||
libffmpegthumbnailer-dev \ | libffmpegthumbnailer-dev \ | ||
libavcodec-dev \ | libavcodec-dev \ | ||
libxmu-dev \ | libxmu-dev \ | ||
libavformat-dev libswscale-dev | libavformat-dev libswscale-dev -y | ||
</source> | </source> | ||
Update wxpython: | |||
<source lang="bash"> | |||
# be sure to pick the correct Ubuntu version | |||
pip3 install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-22.04 wxPython | |||
</source> | |||
=== Source code download === | |||
Now we have all "ingredients" readily installed on our system. | Now we have all "ingredients" readily installed on our system. | ||
Line 78: | Line 92: | ||
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): | 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:''' | '''a) Download of the weekly source code snapshot (not recommended):''' | ||
<source lang="bash"> | <source lang="bash"> | ||
# download latest GRASS GIS | # download latest GRASS GIS 8.x stable release source code: | ||
mkdir $HOME/src/ | mkdir $HOME/src/ | ||
cd $HOME/src/ | cd $HOME/src/ | ||
wget https://grass.osgeo.org/ | wget https://grass.osgeo.org/grass84/source/snapshot/grass-8.4.git_src_snapshot_latest.tar.gz | ||
# Unpack source code package and remove tarball archive: | # Unpack source code package and remove tarball archive: | ||
tar xvfz grass- | tar xvfz grass-8.4.git_src_snapshot_latest.tar.gz | ||
rm -f grass- | rm -f grass-8.4.git_src_snapshot_latest.tar.gz | ||
# rename source code directory | # rename source code directory (yes, with the questionmarks!) | ||
mv grass- | mv grass-8.4.git_src_snapshot_20??_??_?? grass-8.4.latest | ||
cd grass- | cd grass-8.4.latest/ | ||
</source> | </source> | ||
'''b) Download of the current development version from GitHub (adopt the path below accordingly)''' | '''b) Download of the current development version from GitHub (adopt the path below accordingly)''' | ||
Note: to find the current version number (8_x), see https://github.com/OSGeo/grass/branches: | |||
<source lang="bash"> | <source lang="bash"> | ||
git clone https://github.com/OSGeo/grass.git grass- | sudo apt-get install git | ||
cd grass- | git clone https://github.com/OSGeo/grass.git grass-8.4.latest.git | ||
git checkout | cd grass-8.4.latest.git/ | ||
git checkout releasebranch_8_4 | |||
</source> | </source> | ||
=== Compilation === | |||
Now we can '''compile''' the source code in order to generate the GRASS GIS binaries: | Now we can '''compile''' the source code in order to generate the GRASS GIS binaries: | ||
Line 119: | Line 138: | ||
--with-nls \ | --with-nls \ | ||
--with-zstd \ | --with-zstd \ | ||
--with-pdal \ | --with-pdal \ | ||
--with-cairo --with-cairo-ldflags=-lfontconfig \ | --with-cairo --with-cairo-ldflags=-lfontconfig \ | ||
Line 125: | Line 143: | ||
--with-wxwidgets \ | --with-wxwidgets \ | ||
--with-fftw \ | --with-fftw \ | ||
--with- | --with-openmp \ | ||
--with-opengl-libs=/usr/include/GL \ | --with-opengl-libs=/usr/include/GL \ | ||
--with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \ | --with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \ | ||
Line 131: | Line 149: | ||
--without-mysql \ | --without-mysql \ | ||
--without-odbc \ | --without-odbc \ | ||
--without-ffmpeg | --without-ffmpeg | ||
</source> | </source> | ||
Now compile source code ( | Now compile the source code (this will take some time as it generates binary code from the source code): | ||
<source lang="bash"> | <source lang="bash"> | ||
# note: the more CPUs you have, the higher the -j number may be set to | # note: the more CPUs you have, the higher the -j number may be set to | ||
Line 142: | Line 159: | ||
</source> | </source> | ||
Install resulting GRASS GIS | === Installation === | ||
Install resulting GRASS GIS binaries into /usr/local/: | |||
<source lang="bash"> | <source lang="bash"> | ||
sudo make install | sudo make install | ||
Line 149: | Line 168: | ||
Start GRASS GIS in the terminal: | Start GRASS GIS in the terminal: | ||
<source lang="bash"> | <source lang="bash"> | ||
grass | |||
</source> | </source> | ||
'''Done & enjoy!''' | |||
== Hints == | == Hints == | ||
Line 157: | Line 178: | ||
* 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. | * 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. | ||
== Pre-compiled packages and backports == | |||
'''Pre-compiled packages and backports''' are available from [https://wiki.ubuntu.com/UbuntuGIS UbuntuGIS] via their [https://launchpad.net/~ubuntugis/+archive/ppa/ ppa.launchpad stable] and [https://launchpad.net/~ubuntugis/+archive/ubuntu/ubuntugis-unstable ppa.launchpad unstable] 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.''' | |||
Version overview: | |||
* noble 8.3 | |||
* jammy (22.04): 8.3 | |||
* focal (20.04 LTS): 8.2 | |||
* bionic (18.04 LTS): 7.8 | |||
* xenial (16.04 LTS): 7.6 | |||
* trusty (14.04 LTS): 7.4 | |||
a) Daily ready-to-install GRASS GIS builds of the stable release branch and master are available from ''ppa:grass/grass-devel'': | |||
<source lang=bash> | |||
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable | |||
sudo add-apt-repository ppa:grass/grass-devel | |||
</source> | |||
b) Latest packaged stable version of GRASS GIS is available from ''ppa:grass/grass-stable'': | |||
<source lang=bash> | |||
sudo add-apt-repository ppa:ubuntugis/ppa | |||
sudo add-apt-repository ppa:grass/grass-stable | |||
sudo apt-get update | |||
sudo apt-get install grass | |||
</source> | |||
== Dependencies == | == Dependencies == | ||
Line 188: | Line 236: | ||
libreadline6 libreadline6-dev libfreetype6-dev \ | libreadline6 libreadline6-dev libfreetype6-dev \ | ||
libfftw3-3 libfftw3-dev \ | libfftw3-3 libfftw3-dev \ | ||
libboost-thread-dev libboost-program-options | libboost-thread-dev libboost-program-options-dev \ | ||
resolvconf \ | resolvconf \ | ||
libjasper-dev \ | libjasper-dev \ | ||
git \ | |||
libav-tools libavutil-dev ffmpeg2theora \ | libav-tools libavutil-dev ffmpeg2theora \ | ||
libffmpegthumbnailer-dev \ | libffmpegthumbnailer-dev \ | ||
Line 214: | Line 262: | ||
libtiff-dev libpnglite-dev \ | libtiff-dev libpnglite-dev \ | ||
sqlite3 libsqlite3-dev \ | sqlite3 libsqlite3-dev \ | ||
libboost-thread-dev libboost-program-options | libboost-thread-dev libboost-program-options-dev \ | ||
resolvconf \ | resolvconf \ | ||
git \ | |||
checkinstall \ | checkinstall \ | ||
cmake ccache \ | cmake ccache \ | ||
Line 238: | Line 286: | ||
* See the additional packages bellow and in other sections and install them. Note that some of them are [ | * See the additional packages bellow and in other sections and install them. Note that some of them are [https://github.com/OSGeo/grass/blob/main/REQUIREMENTS.md required], namely PROJ, GEOS and GDAL. If you don't have special requirements, it is usually enough just to install PROJ, GEOS and GDAL from repository (rather then compile them manually). | ||
* for mysql support, <source lang="bash" enclose="none">libmysqlclient-dev</source> is required | * for mysql support, <source lang="bash" enclose="none">libmysqlclient-dev</source> is required | ||
Line 265: | Line 313: | ||
sudo chmod ug+rwx /usr/local/src</source> | sudo chmod ug+rwx /usr/local/src</source> | ||
== | == Using pre-compiled dev Packages for PROJ, GEOS and GDAL == | ||
=== PROJ === | |||
=== PROJ | |||
Install the <source lang="bash" enclose="none">dev</source> package: | Install the <source lang="bash" enclose="none">dev</source> package: | ||
Line 331: | Line 357: | ||
[[Compile_and_Install_Ubuntu#GRASS_GIS|Jump to sub-section GRASS-GIS below]] | [[Compile_and_Install_Ubuntu#GRASS_GIS|Jump to sub-section GRASS-GIS below]] | ||
== Using pre-compiled dev Packages for PROJ | == Using pre-compiled dev Packages for PROJ, GEOS and GDAL from GIS.lab PPA== | ||
Ivan Mincik has made all required packages available in his [https://launchpad.net/~imincik/+archive/ubuntu/gis PPA]: | Ivan Mincik has made all required packages available in his [https://launchpad.net/~imincik/+archive/ubuntu/gis PPA]: | ||
Line 340: | Line 366: | ||
</source> | </source> | ||
Now you can either also install GRASS GIS | Now you can either also install GRASS GIS from there or compile it yourself (see [[Compile_and_Install_Ubuntu#GRASS_GIS|Jump to sub-section GRASS-GIS below]]) | ||
== Compile from source == | == Compile from source == | ||
=== | === PROJ === | ||
* 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 | * 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 GitHub repository: <source lang="bash"> | ||
https://github.com/OSGeo/PROJ/ | |||
</source> | </source> | ||
* get [http://download.osgeo.org/proj/proj-datumgrid-1. | * get [http://download.osgeo.org/proj/proj-datumgrid-1.8.zip '''proj-datumgrid-1.8.zip'''] or related files from [https://trac.osgeo.org/proj proj' trac] and move it under <source lang="bash" enclose="none">proj/nad</source> | ||
<ul><source lang="bash"> | <ul><source lang="bash"> | ||
wget http://download.osgeo.org/proj/proj-datumgrid-1. | wget http://download.osgeo.org/proj/proj-datumgrid-1.8.zip | ||
mv proj-datumgrid-1. | mv proj-datumgrid-1.8.zip /usr/local/src/proj/nad | ||
cd /usr/local/src/proj/nad | cd /usr/local/src/proj/nad | ||
</source> | </source> | ||
Line 360: | Line 386: | ||
* decompress it <source lang="bash"> | * decompress it <source lang="bash"> | ||
unzip proj-datumgrid-1. | unzip proj-datumgrid-1.8.zip | ||
</source> | </source> | ||
Line 389: | Line 415: | ||
=== GEOS === | === GEOS === | ||
* download '''geos-3. | * download '''geos-3.12.2.tar.bz2''' from [https://libgeos.org/ https://libgeos.org/] using <source lang="bash" enclose="none">wget</source> <source lang="bash"> | ||
wget | wget https://download.osgeo.org/geos/geos-3.12.2.tar.bz2 | ||
</source> | </source> | ||
Line 396: | Line 422: | ||
<ul><source lang="bash"> | <ul><source lang="bash"> | ||
cd /usr/local/src/ | cd /usr/local/src/ | ||
bunzip2 geos-3. | bunzip2 geos-3.12.2.tar.bz2 | ||
tar xvf geos-3. | tar xvf geos-3.12.2.tar | ||
</source> | </source> | ||
</ul> | </ul> | ||
Line 406: | Line 432: | ||
* move to geos directory <source lang="bash"> | * move to geos directory <source lang="bash"> | ||
cd geos-3. | cd geos-3.12.2 | ||
</source> | </source> | ||
Line 423: | Line 449: | ||
=== GDAL === | === GDAL === | ||
'''Note''', GDAL must be compiled '''without''' GRASS support | '''Note''', GDAL must be compiled '''without''' GRASS support! | ||
* | * download the current stable version (see https://github.com/OSGeo/gdal/releases for latest version): | ||
./ | |||
<source lang="bash"> | <source lang="bash"> | ||
wget https://github.com/OSGeo/gdal/releases/download/v3.9.1/gdal-3.9.1.tar.gz | |||
- | |||
</source> | </source> | ||
Follow the instructions to compile GDAL: | |||
https://gdal.org/development/building_from_source.html | |||
=== GRASS GIS === | === GRASS GIS === | ||
Note the differences between different GRASS version ( | Note the differences between different GRASS GIS version (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 <code>INSTALL</code> file, which is located in GRASS' source code root directory | To fully understand the build process, read the <code>INSTALL</code> file, which is located in GRASS' source code root directory. | ||
''' Getting GRASS' source code ''' | ''' Getting GRASS' source code ''' | ||
Select from one of the GRASS GIS versions and download | Select from one of the GRASS GIS versions and download the source code: | ||
https://github.com/OSGeo/grass/releases/ | |||
''' Configure, Compile and Install''' | ''' Configure, Compile and Install''' | ||
Enter the directory with the source code | Enter the directory with the source code, for example: | ||
<source lang="bash"> | <source lang="bash"> | ||
cd | cd grass | ||
</source> | </source> | ||
* '''GRASS GIS | * '''GRASS GIS example configuration''' (which can/should be adjusted according to specific needs): | ||
<ul> | <ul> | ||
<source lang="bash"> | <source lang="bash"> | ||
CFLAGS="-O2 -Wall" LDFLAGS="-s" ./configure \ | CFLAGS="-O2 -Wall" LDFLAGS="-s" ./configure \ | ||
--with-nls \ | --with-nls \ | ||
--with-cxx \ | --with-cxx \ | ||
--with-proj-share=/usr/local/share/proj/ \ | --with-proj-share=/usr/local/share/proj/ \ | ||
--with-geos=/usr/local/bin/geos-config \ | --with-geos=/usr/local/bin/geos-config \ | ||
Line 558: | Line 495: | ||
--with-mysql=yes --with-mysql-includes="/usr/include/mysql" \ | --with-mysql=yes --with-mysql-includes="/usr/include/mysql" \ | ||
--with-odbc=no \ | --with-odbc=no \ | ||
--with- | --with-pdal | ||
</source> | </source> | ||
</ul> | </ul> | ||
<ul> | <ul> | ||
'''Note''', the above configuration uses the <code> | '''Note''', the above configuration uses the <code>PROJ</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"> | <source lang="bash"> | ||
--with-proj-share=/usr/share/proj \ | --with-proj-share=/usr/share/proj \ | ||
--with-geos=/usr/bin/geos-config \ | --with-geos=/usr/bin/geos-config \ | ||
</source> | </source> | ||
</ul> | </ul> | ||
Line 595: | Line 531: | ||
=== GDAL-GRASS-Plugin === | === GDAL-GRASS-Plugin === | ||
* get the plugin from [ | See: https://github.com/OSGeo/gdal-grass | ||
* get the plugin from [https://github.com/OSGeo/gdal-grass/releases GitHub]: "gdal-grass-X.Y.Z.tar.gz" using <source lang="bash" enclose="none">wget</source> | |||
<ul><source lang="bash"> | <ul><source lang="bash"> | ||
wget | # update version number accordingly! | ||
tar xvzf gdal-grass-1. | wget https://github.com/OSGeo/gdal-grass/archive/refs/tags/1.0.2.tar.gz -O gdal-grass-1.0.2.tar.gz | ||
cd gdal-grass-1. | tar xvzf gdal-grass-1.0.2.tar.gz | ||
cd gdal-grass-1.0.2 | |||
</source></ul> | </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: | * 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"> | <ul><source lang="bash"> | ||
# GRASS | # GRASS GIS stable library path (adapt as needed) | ||
/usr/local/src/ | /usr/local/src/releasebranch_8_4/lib | ||
# GRASS | # GRASS GIS development version library path (adapt as needed) | ||
/usr/local/src/ | /usr/local/src/grass_master/lib | ||
</source></ul> | </source></ul> | ||
Line 624: | Line 557: | ||
--prefix=/usr/local \ | --prefix=/usr/local \ | ||
--with-gdal=/usr/local/bin/gdal-config \ | --with-gdal=/usr/local/bin/gdal-config \ | ||
--with-grass=/usr/local/grass | --with-grass=/usr/local/grass/ \ | ||
--with-autoload="/usr/local/ | --with-autoload="/usr/local/lib64/gdalplugins/" \ | ||
--with-ld-shared="g++ -shared"</source></ul> | --with-ld-shared="g++ -shared"</source></ul> | ||
</ul> | </ul> | ||
Line 638: | Line 567: | ||
= Post compilation/installation control = | = Post compilation/installation control = | ||
* For a recommended quick-check read the [ | * For a recommended quick-check read the [https://grass.osgeo.org/wiki/Compile_and_install_GRASS_and_QGIS_with_GDAL/OGR_Plugin#Troubleshooting Troubleshooting] section at [https://grass.osgeo.org/wiki/Compile_and_install_GDAL-GRASS_plugin Compile_and_install_GDAL-GRASS_plugin] | ||
* in case of errors in future compilation attempts, remember to remove program binaries and files created with the "configuration" from previous compilations with | * in case of errors in future compilation attempts, remember to remove program binaries and files created with the "configuration" from previous compilations with | ||
Line 649: | Line 578: | ||
To get rid of a GRASS binaries installation, delete | To get rid of a GRASS binaries installation, delete (update version numbers accordingly) | ||
* <source lang="bash" enclose="none">/usr/local/grass | * <source lang="bash" enclose="none">/usr/local/grass</source> (directory, binaries location) | ||
* <source lang="bash" enclose="none">/usr/local/bin/ | * <source lang="bash" enclose="none">/usr/local/bin/grass</source> (file) | ||
* <source lang="bash" enclose="none">/home/username/.grassrc8</source> (file) | |||
* <source lang="bash" enclose="none">/home/username/. | |||
If wanted, delete also the complete source code: | If wanted, delete also the complete source code: | ||
* <source lang="bash" enclose="none">/usr/local/src/ | * <source lang="bash" enclose="none">/usr/local/src/grass_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"> | 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 | sudo dpkg -r grass # package name defined at installation is important</source> | ||
== See also == | == See also == | ||
* Docker: https://grass.osgeo.org/download/docker/ | |||
* Docker: https:// | |||
* [[Ubuntu Packaging]] | * [[Ubuntu Packaging]] | ||
* [[GRASS in Debian]] | * [[GRASS in Debian]] | ||
Line 679: | Line 599: | ||
Notes that concern the configuration and compilation of GRASS GIS and its dependencies for older versions of Ubuntu-Linux. | Notes that concern the configuration and compilation of GRASS GIS and its dependencies for older versions of Ubuntu-Linux. | ||
[[Category: Compilation]] | [[Category: Compilation]] |
Latest revision as of 07:59, 31 July 2024
Quick instructions
These instructions should work fine on Ubuntu distributions:
Install geospatial dependencies
1. Install some dependencies (PROJ, GEOS, GDAL libraries) and the compiler tools
(note: you need Python 3)
# be sure to have an updated system
sudo apt update && sudo apt upgrade -y
# install PROJ
sudo apt install libproj-dev proj-data proj-bin unzip -y
# optionally, install (selected) datum grid files
sudo apt-get install proj-data
# install GEOS
sudo apt install libgeos-dev -y
# install GDAL
sudo apt install libgdal-dev python3-gdal gdal-bin -y
# install PDAL (optional)
sudo apt install libpdal-dev pdal -y
# Python3 precedence over Python2 (which is end-of-life since 2019, so it should be the default anyway)
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:
Install further compilation dependencies (Ubuntu 22.04)
For Ubuntu 22.04:
sudo apt-get install \
build-essential \
flex make bison gcc libgcc1 g++ ccache \
python3 python3-dev python3-pip \
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 \
libpdal-dev libpq-dev \
libreadline-dev libfreetype6-dev \
libfftw3-3 libfftw3-dev \
libboost-thread-dev libboost-program-options-dev \
git libzstd-dev \
checkinstall \
libglu1-mesa-dev libxmu-dev \
ghostscript wget -y
For NVIZ on Ubuntu:
sudo apt-get install \
ffmpeg libavutil-dev ffmpeg2theora \
libffmpegthumbnailer-dev \
libavcodec-dev \
libxmu-dev \
libavformat-dev libswscale-dev -y
Update wxpython:
# be sure to pick the correct Ubuntu version
pip3 install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-22.04 wxPython
Source code download
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 8.x stable release source code:
mkdir $HOME/src/
cd $HOME/src/
wget https://grass.osgeo.org/grass84/source/snapshot/grass-8.4.git_src_snapshot_latest.tar.gz
# Unpack source code package and remove tarball archive:
tar xvfz grass-8.4.git_src_snapshot_latest.tar.gz
rm -f grass-8.4.git_src_snapshot_latest.tar.gz
# rename source code directory (yes, with the questionmarks!)
mv grass-8.4.git_src_snapshot_20??_??_?? grass-8.4.latest
cd grass-8.4.latest/
b) Download of the current development version from GitHub (adopt the path below accordingly)
Note: to find the current version number (8_x), see https://github.com/OSGeo/grass/branches:
sudo apt-get install git
git clone https://github.com/OSGeo/grass.git grass-8.4.latest.git
cd grass-8.4.latest.git/
git checkout releasebranch_8_4
Compilation
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-pdal \
--with-cairo --with-cairo-ldflags=-lfontconfig \
--with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
--with-wxwidgets \
--with-fftw \
--with-openmp \
--with-opengl-libs=/usr/include/GL \
--with-postgres=yes --with-postgres-includes="/usr/include/postgresql" \
--without-netcdf \
--without-mysql \
--without-odbc \
--without-ffmpeg
Now compile the source code (this will take 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
Installation
Install resulting GRASS GIS binaries into /usr/local/:
sudo make install
Start GRASS GIS in the terminal:
grass
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 ofsudo 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
ormake -j3
or evenmake -j4
) which specify the number of jobs (commands) to run simultaneously.
Pre-compiled packages and backports
Pre-compiled packages and backports are available from UbuntuGIS via their ppa.launchpad stable and ppa.launchpad unstable 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.
Version overview:
- noble 8.3
- jammy (22.04): 8.3
- focal (20.04 LTS): 8.2
- bionic (18.04 LTS): 7.8
- xenial (16.04 LTS): 7.6
- trusty (14.04 LTS): 7.4
a) Daily ready-to-install GRASS GIS builds of the stable release branch and master are available from ppa:grass/grass-devel:
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo add-apt-repository ppa:grass/grass-devel
b) Latest packaged stable version of GRASS GIS 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 grass
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 \
resolvconf \
libjasper-dev \
git \
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 \
resolvconf \
git \
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, GEOS and GDAL. If you don't have special requirements, it is usually enough just to install PROJ, 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
andlibnetcdf-dev
is required
sudo apt-get install netcdf-bin libnetcdf-dev
- for i.spec.unmix Addon support, install LAPACK and BLAS:
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 createdsudo 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 thesrc
directory:sudo chmod ug+rwx /usr/local/src
Using pre-compiled dev Packages for PROJ, GEOS and GDAL
PROJ
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, 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 from there or compile it yourself (see Jump to sub-section GRASS-GIS below)
Compile from source
PROJ
- within the directory
/usr/local/src
(create it if it does not exist) checkoutproj
from its GitHub repository:https://github.com/OSGeo/PROJ/
- get proj-datumgrid-1.8.zip or related files from proj' trac and move it under
proj/nad
wget http://download.osgeo.org/proj/proj-datumgrid-1.8.zip
mv proj-datumgrid-1.8.zip /usr/local/src/proj/nad
cd /usr/local/src/proj/nad
- decompress it
unzip proj-datumgrid-1.8.zip
- go back to the
proj
directorycd /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 runsudo ldconfig
- finally, go back to the parent directory simply by instructing
cd ..
GEOS
- download geos-3.12.2.tar.bz2 from https://libgeos.org/ using
wget
wget https://download.osgeo.org/geos/geos-3.12.2.tar.bz2
- move to the "source-code" directory and decompress
cd /usr/local/src/
bunzip2 geos-3.12.2.tar.bz2
tar xvf geos-3.12.2.tar
- if required, clean previous configuration & compilation
make distclean
- move to geos directory
cd geos-3.12.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 (see https://github.com/OSGeo/gdal/releases for latest version):
wget https://github.com/OSGeo/gdal/releases/download/v3.9.1/gdal-3.9.1.tar.gz
Follow the instructions to compile GDAL: https://gdal.org/development/building_from_source.html
GRASS GIS
Note the differences between different GRASS GIS version (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.
Getting GRASS' source code
Select from one of the GRASS GIS versions and download the source code:
https://github.com/OSGeo/grass/releases/
Configure, Compile and Install
Enter the directory with the source code, for example:
cd grass
- GRASS GIS example configuration (which can/should be adjusted according to specific needs):
CFLAGS="-O2 -Wall" LDFLAGS="-s" ./configure \
--with-nls \
--with-cxx \
--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-pdal
-
Note, the above configuration uses the
PROJ
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 \
- 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
See: https://github.com/OSGeo/gdal-grass
- get the plugin from GitHub: "gdal-grass-X.Y.Z.tar.gz" using
wget
# update version number accordingly!
wget https://github.com/OSGeo/gdal-grass/archive/refs/tags/1.0.2.tar.gz -O gdal-grass-1.0.2.tar.gz
tar xvzf gdal-grass-1.0.2.tar.gz
cd gdal-grass-1.0.2
- create
/etc/ld.so.conf.d/grass.conf
or add in/etc/ld.so.conf
the GRASS library path:
# GRASS GIS stable library path (adapt as needed)
/usr/local/src/releasebranch_8_4/lib
# GRASS GIS 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/ \
--with-autoload="/usr/local/lib64/gdalplugins/" \
--with-ld-shared="g++ -shared"
- compile & install using checkinstall
make -j2 && sudo checkinstall
Post compilation/installation control
- For a recommended quick-check read the Troubleshooting section at Compile_and_install_GDAL-GRASS_plugin
- 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
(directory, binaries location)/usr/local/bin/grass
(file)/home/username/.grassrc8
(file)
If wanted, delete also the complete source code:
/usr/local/src/grass_release
(directory, source code location)
To remove grass
(or any other package) which was installed by checkinstall
, use dpkg
, e.g.
sudo dpkg -r grass # package name defined at installation is important
See also
Archived Notes
Notes that concern the configuration and compilation of GRASS GIS and its dependencies for older versions of Ubuntu-Linux.