Compile and Install Ubuntu: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
Line 196: Line 196:
=== GEOS ===
=== GEOS ===


* download '''geos-3.3.8.tar.bz2''' from [http://trac.osgeo.org/geos/ http://trac.osgeo.org/geos] using <source lang="bash" enclose="none">wget</source> <source lang="bash">
* download '''geos-3.4.1.tar.bz2''' from [http://trac.osgeo.org/geos/ http://trac.osgeo.org/geos] using <source lang="bash" enclose="none">wget</source> <source lang="bash">
wget http://download.osgeo.org/geos/geos-3.3.8.tar.bz2
wget http://download.osgeo.org/geos/geos-3.4.1.tar.bz2
</source>
</source>


Line 203: Line 203:
<ul><source lang="bash">
<ul><source lang="bash">
cd /usr/local/src/
cd /usr/local/src/
bunzip2 geos-3.3.8.tar.bz2
bunzip2 geos-3.4.1.tar.bz2
tar xvf  geos-3.3.8.tar
tar xvf  geos-3.4.1.tar
</source>
</source>
   </ul>
   </ul>
Line 213: Line 213:


* move to geos directory  <source lang="bash">
* move to geos directory  <source lang="bash">
cd geos-3.3.8
cd geos-3.4.1
</source>
</source>



Revision as of 23:58, 18 August 2013

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 described below.
  • 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.
  • 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 this page respectively.
  • GRASS version 6.5 exists for development purposes, testing features to-be backported to version 6.4. As such it may include unstable code and is not intended for production and end-users.
  • 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
    
(you'll need to have the deb-src lines active in your /etc/apt/sources.list file)

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

The following dependencies concern Ubuntu Raring Ringtail (13.04)

  • 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; the following action will also install various dependencies (listed in the command line as The following extra packages will be installed:...):
    # 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-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 \
      lesstif2-dev libtiff-dev libpnglite-dev \
      tcl8.5-dev tk8.5-dev \
      libcairo2 libcairo2-dev \
      sqlite3 libsqlite3-dev \
      libpq-dev \
      libreadline6 libreadline6-dev libfreetype6-dev \
      txt2tags \
      libfftw3-3 libfftw3-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 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
    
  • 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 (possibly without support for datumgrid):

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/


GEOS

Install the dev package:

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


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.1.tar.bz2
    tar xvf  geos-3.4.1.tar
    
  • if required, clean previous configuration & compilation
    make distclean
    
  • move to geos directory
    cd geos-3.4.1
    
  • 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.10/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

Getting GRASS' source code

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

To download under development versions use

  • for GRASS 6.5 (Note: GRASS version 6.5 is not intended for end-users! It exists for development purposes which should rather take place for GRASS 7.)
    svn co https://svn.osgeo.org/grass/grass/branches/develbranch_6 grass6_devel
    
  • for GRASS 7
    svn co https://svn.osgeo.org/grass/grass/trunk grass7_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):
    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-postgresql=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 \
    
  • compile & install
    make -j2  &&  sudo make install  &&  sudo ldconfig
    
    or
    make -j2  &&  sudo checkinstall  &&  sudo ldconfig
    

GDAL-GRASS-Plugin

    wget http://download.osgeo.org/gdal/gdal-grass-1.4.3.tar.gz
    tar xvzf gdal-grass-1.4.3.tar.gz
    cd gdal-grass-1.4.3
    
  • create /etc/ld.so.conf.d/grass.conf or add in /etc/ld.so.conf the GRASS library path:
    # GRASS 6.4 library path
    /usr/local/src/grass64_release/lib
    
    # GRASS 6.5 library path
    /usr/local/src/grass6_devel/lib
    
    # GRASS 7.0 library path
    /usr/local/src/grass7_trunk/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-6.4.4svn/ \
     --with-autoload="/usr/local/lib/gdalplugins/" \
     --with-ld-shared="g++ -shared"
    
    • for GRASS 6.5, replace the respective line above, depending on where the source code in question is stored, with something like --with-grass=/usr/local/grass-6.5.svn/
    • for GRASS 7, replace with --with-grass=/usr/local/grass_trunk/
  • 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

  • /usr/local/grass-6.4.4svn (directory, binaries location)
  • /usr/local/bin/grass64 (file)
  • /usr/local/bin/gem64 (file)
  • /home/username/.grassrc6 (file)


If wanted, delete also the complete source code:

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


To remove grass (or any other package) which was installed by checkinstall, use dpkg, e.g.

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

Packaging of GRASS

  • See the debian/README.debian file in the GRASS source code 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

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