Compile and Install Ubuntu

From GRASS-Wiki
Revision as of 19:52, 2 November 2012 by ⚠️NikosA (talk | contribs) (→‎Hints: ''make -j3'' also useful!)
Jump to navigation Jump to search
  • 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.
  • An alternate method is to use the DebianGIS packaging scripts, which enable a lot of this to happen automatically (see debian/README.debian in the GRASS Subversion source code repository). Specifically, this command will get you 90% of the way there:
sudo apt-get build-dep grass


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

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: 78455 and 599163. Useful information on the use of checkinstall: 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 -j3" or make -j4) which specify the number of jobs (commands) to run simultaneously.

Dependencies

  • update the system from the repositories
sudo apt-get update && sudo apt-get upgrade
  • 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:):
sudo apt-get install \
 build-essential \
 make flex bison gcc libgcc1 g++ cmake ccache \
 python python-dev python-qt4 python-qt4-dev \
 python-opengl \
 python-wxversion python-wxtools python-wxgtk2.8 \
 python-dateutil libgsl0-dev python-numpy \
 wx2.8-headers wx-common libwxgtk2.8-dev libwxgtk2.8-dbg \
 libwxbase2.8-dev  libwxbase2.8-dbg \
 libncurses5-dev \
 zlib1g-dev gettext \
 libtiff4-dev libpngwriter-dev \
 tcl8.4-dev tk8.4-dev \
 libcairo libcairo-dev \
 sqlite3 libsqlite3-dev \
 libpq-dev \
 libreadline5 libreadline5-dev libfreetype6-dev \
 txt2tags \
 fftw3 fftw3-dev \
 libqt4-core libqt4-dbg libqt4-dev libqt4-gui libqt4-sql libqt4-qt3support \
 lsb-qt4 qt4-designer qt4-dev-tools qt4-doc qt4-qtconfig \
 libapt-pkg-perl resolvconf \
 libjasper-dev \
 ruby \
 subversion \
 ffmpeg ffmpeg2theora \
 libffmpegthumbnailer-dev \
 libavcodec-dev \
 libxmu-dev \
 libavformat-dev libswscale-dev \
 checkinstall \
 libglu1-mesa-dev libxmu-dev
  • 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

(caveat: allegedly works for me - can someone please confirm? //Stefan )
  • for Ubuntu Lucid Lynx (10.04) or later, also install:
sudo apt-get install libhdf4-alt-dev libhdf4-0-alt
  • for earlier Ubuntu versions, also install:
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)
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

PROJ4

Use either the packaged version (possibly without support for datumgrid), or compile from source:

Packaged version

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

Compiled from source

  • 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/
mv proj-datumgrid-1.5.tar.gz /usr/local/src/proj/nad
cd /usr/local/src/proj/nad
  • decompress it
unzip proj-datumgrid-1.5.zip
  • go to 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
  • go to src directory
cd /usr/local/src

GEOS

Use either the packaged version, or compile from source:

Packaged version

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

Compiled from source

wget http://download.osgeo.org/geos/geos-3.3.5.tar.bz2
  • move to the "source-code" directory and decompress
cd /usr/local/src/
bunzip2 geos-3.3.5.tar.bz2
tar xvf  geos-3.3.5.tar
  • if required, clean previous configuration & compilation
make distclean
  • move to geos directory
cd geos-3.3.5
  • simple configure, compile and install
./configure  &&  make  &&  sudo make install
  • ensure that /usr/local/lib is added to /etc/ld.so.conf and run /sbin/ldconfig afterwards
sudo ldconfig

GDAL

Use either the packaged version (possibly without support for datumgrid), or compile from source:

Packaged version

sudo apt-get install libgdal-dev
  • 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:
sudo apt-get install <package>=<required.version>

Compiled from source

  • GDAL must be compiled without GRASS support
  • download current stable version
svn checkout https://svn.osgeo.org/gdal/branches/1.9/gdal gdal_stable
  • enter in directory gdal_stable
cd /usr/local/src/gdal_stable
  • optionally, update the source code
svn up
  • if required, clean previous configurations/compilations
make distclean
  • configure
CFLAGS="-g -Wall" LDFLAGS="-s" ./configure \
--with-png=internal \
--with-libtiff=internal \
--with-geotiff=internal \
--with-jpeg=internal \
--with-gif=internal \
--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
make && sudo make install && sudo ldconfig

GRASS GIS

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

Getting GRASS' source code

  • get current state of the 6.4.x release branch version (stable)
 svn checkout https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4 grass64_release

To download under development versions use:

  • for GRASS 6.5 (reminder: * GRASS version 6.5 exists for development purposes and is not intended for end-users)
svn checkout https://svn.osgeo.org/grass/grass/branches/develbranch_6 grass6_devel
  • for GRASS 7
svn checkout https://svn.osgeo.org/grass/grass/trunk grass_trunk
  • for subsequent updates execute:
svn up

Configure, Compile and Install

  • if required, clean previous configuration & compilation (not needed the first time)
make distclean
  • example configuration (which can/should be adjusted according to specific needs):
./configure \
--with-cxx \
--enable-largefile=yes \
--with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
--with-proj-share=/usr/local/share/proj/ \
--with-geos \
--with-cairo \
--with-tcltk-includes=/usr/include/tcl8.4/ --with-tcltk-libs=/usr/lib/ \
--with-wxwidgets \
--with-postgres=no \
--with-sqlite=yes \
--with-python=/usr/bin/python2.7-config \
--with-opengl-libs=/usr/include/GL \
--with-ffmpeg=yes \
--with-ffmpeg-includes="/usr/include/libavcodec /usr/include/libavformat /usr/include/libswscale"

Note: when using PROJ 4 from repository, replace above related line with "--with-proj-share=/usr/share/proj/ \"

  • compile & install
make -j2 && sudo make install && sudo ldconfig
  • alternatively, checkinstall can be used instead of make install. A deb package will be created and installed (which can be easily uninstalled)
make -j2 && sudo checkinstall && sudo ldconfig

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

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

  • /usr/local/src/grass_64svn (folder, source code location)

To remove grass (or any other package) installed by using checkinstall, e.g.

sudo dpkg -r grass64 # package name defined at installation is important