Compile and Install Ubuntu: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
m (→‎Dependencies: improved formatting)
m (Improving formatting (intermediate state -- do not use or revert here!))
Line 9: Line 9:
* 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 described below.'''
* 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 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.
* 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 <source lang="bash" enclose="none">debian/</source> 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 the wiki respectively.
* 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 for testing features to-be backported to version 6.4. As such it may include unstable code and is not intended for end-users.
* 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 [https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4/debian/README.debian debian/README.debian] in the GRASS Subversion source code repository). Specifically, this command will get you 90% of the way there:
* 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 GRASS Subversion source code repository). Specifically, this command will get you 90% of the way there: <source lang="bash">sudo apt-get build-dep grass</source>
sudo apt-get build-dep grass




== 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 '''make''' 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 -j3'' 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 ==


The following dependecies concern [http://releases.ubuntu.com/quantal/ Ubuntu Quantal Quetzal (12.10)]
=== Current stable Ubuntu version ===


* First, update the system from the repositories
The following dependencies concern [http://releases.ubuntu.com/quantal/ Ubuntu Quantal Quetzal (12.10)]
<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; 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>...):
* First, update the system from the repositories<source lang="bash">
<source lang="bash">
sudo apt-get update && sudo apt-get upgrade
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 \
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
</source>
</source>


* for mysql support, <source lang="bash" enclose="none">libmysqlclient-dev</source> is required
* 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 <source lang="bash" enclose="none">The following extra packages will be installed:</source>...):<br/>
<source lang="bash">sudo apt-get install libmysqlclient-dev</source>
<source lang="bash">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 \
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
</source>


** for [http://releases.ubuntu.com/precise/ Ubuntu Precise Pangolin (12.04)], change the following dependencies:
* for mysql support, <source lang="bash" enclose="none">libmysqlclient-dev</source> is required <source lang="bash">
<source lang="bash" enclose="none">libpnglite-dev</source> --> <source lang="bash" enclose="none">libpngwriter-dev</source><br/>
sudo apt-get install libmysqlclient-dev
<source lang="bash" enclose="none">libtiff5-dev</source> --> <source lang="bash" enclose="none">libtiff4-dev</source>
</source>
 
** for [http://old-releases.ubuntu.com/releases/maverick/ Ubuntu Maverick Meerkat (10.10)] or later, change the following dependencies:
<source lang="bash" enclose="none">libpngwriter-dev</source> --> <source lang="bash" enclose="none">libpngwriter0-dev</source><br/>
<source lang="bash" enclose="none">libcairo-dev</source> --> <source lang="bash" enclose="none">libcairo2-dev</source><br/>
<source lang="bash" enclose="none">fftw3</source> --> <source lang="bash" enclose="none">libfftw3-3</source><br/>
<source lang="bash" enclose="none">fftw3-dev</source> --> <source lang="bash" enclose="none">libfftw3-dev</source>
 
** 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 [http://old-releases.ubuntu.com/releases/ earlier Ubuntu versions], also install:
<source lang="bash">sudo apt-get install libhdf4g-dev libhdf4g-run</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
* 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>
<source lang="bash">
sudo mkdir /usr/local/src
</source>


* grant <source lang="bash" enclose="none">rwx</source> (read-write-execute) permissions for our ''userid'' and ''groupid'' onto the directory ('''replace''' below the terms ''userid'' and ''groupid'' with a real <source lang="bash" enclose="none">userid</source>):
* grant <source lang="bash" enclose="none">rwx</source> (read-write-execute) permissions for our ''userid'' and ''groupid'' onto the directory ('''replace''' below the terms ''userid'' and ''groupid'' with a real <source lang="bash" enclose="none">userid</source>):
Line 98: Line 86:
sudo chmod ug+rwx /usr/local/src
sudo chmod ug+rwx /usr/local/src
</source>
</source>
=== Earlier Ubuntu versions ===
* for [http://releases.ubuntu.com/precise/ Ubuntu Precise Pangolin (12.04)], change the following dependencies:<br/>
<source lang="bash" enclose="none">
libpnglite-dev
</source> --> <source lang="bash" enclose="none">libpngwriter-dev
</source><br/>
<source lang="bash" enclose="none">
libtiff5-dev</source> --> <source lang="bash" enclose="none">libtiff4-dev
</source>
* for [http://old-releases.ubuntu.com/releases/maverick/ Ubuntu Maverick Meerkat (10.10)] or later, change the following dependencies:<br/>
<source lang="bash" enclose="none">
libpngwriter-dev</source> --> <source lang="bash" enclose="none">
libpngwriter0-dev
</source><br/>
<source lang="bash" enclose="none">libcairo-dev
</source> --> <source lang="bash" enclose="none">
libcairo2-dev
</source><br/>
<source lang="bash" enclose="none">
fftw3</source> --> <source lang="bash" enclose="none">
libfftw3-3
</source><br/>
<source lang="bash" enclose="none">
fftw3-dev</source> --> <source lang="bash" enclose="none">
libfftw3-dev
</source>
* for [http://old-releases.ubuntu.com/releases/lucid/ Ubuntu Lucid Lynx (10.04)] or later, also install:<br/>
<source lang="bash">
sudo apt-get install libhdf4-alt-dev libhdf4-0-alt
</source>
* for [http://old-releases.ubuntu.com/releases/ earlier Ubuntu versions], also install:<br/>
<source lang="bash">
sudo apt-get install libhdf4g-dev libhdf4g-run
</source>


== Using pre-compiled dev Packages for PROJ.4, GEOS and GDAL ==
== Using pre-compiled dev Packages for PROJ.4, GEOS and GDAL ==
Line 106: Line 134:
Install the <source lang="bash" enclose="none">dev</source> package (possibly without support for datumgrid):
Install the <source lang="bash" enclose="none">dev</source> package (possibly without support for datumgrid):


sudo apt-get install libproj-dev
<source lang="bash">
sudo apt-get install libproj-dev
</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>
* 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>
Line 116: Line 146:
Install the <source lang="bash" enclose="none">dev</source> package:
Install the <source lang="bash" enclose="none">dev</source> package:


sudo apt-get install libgeos-dev
<source lang="bash">
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>
* 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>
Line 125: Line 157:
Install the <source lang="bash" enclose="none">dev</source> package (possibly without support for datumgrid):
Install the <source lang="bash" enclose="none">dev</source> package (possibly without support for datumgrid):


sudo apt-get install libgdal-dev
<source lang="bash">
sudo apt-get install libgdal-dev
</source>


* Install also the required extra packages (note the message: <source lang="bash" enclose="none">The following extra packages will be installed:</source>)
* Install also the required extra packages (note the message: <source lang="bash" enclose="none">The following extra packages will be installed:</source>)
Line 141: Line 175:
=== PROJ4 ===
=== PROJ4 ===


* within the directory ''/usr/local/src'' (create it if it does not exist) checkout proj from its Subversion repository:
* 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:
svn co http://svn.osgeo.org/metacrs/proj/branches/4.8/proj/
<source lang="bash">
svn co http://svn.osgeo.org/metacrs/proj/branches/4.8/proj/
</source>


* 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'''
* 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>
wget http://download.osgeo.org/proj/proj-datumgrid-1.5.zip
<source lang="bash">
mv proj-datumgrid-1.5.zip /usr/local/src/proj/nad
wget http://download.osgeo.org/proj/proj-datumgrid-1.5.zip
cd /usr/local/src/proj/nad
mv proj-datumgrid-1.5.zip /usr/local/src/proj/nad
cd /usr/local/src/proj/nad
</source>


* decompress it
* decompress it
unzip proj-datumgrid-1.5.zip
<source lang="bash">
unzip proj-datumgrid-1.5.zip
</source>


* go to proj directory
* go to proj directory
cd /usr/local/src/proj
<source lang="bash">
cd /usr/local/src/proj
</source>


* if required, clean previous configuration & compilation
* if required, clean previous configuration & compilation
make distclean
<source lang="bash">
make distclean
</source>


* simple configure, compile and install
* simple configure, compile and install
./configure  &&  make  &&  sudo make install
<source lang="bash">
./configure  &&  make  &&  sudo make install
</source>
 
or
 
<source lang="bash">
make -j2  &&  sudo checkinstall  &&  sudo ldconfig
</source>


* go to src directory
* go to the '''src''' directory
cd /usr/local/src
<source lang="bash">
cd /usr/local/src
</source>




Line 168: Line 222:


* download '''geos-3.3.5.tar.bz2''' from [http://trac.osgeo.org/geos/ http://trac.osgeo.org/geos]
* download '''geos-3.3.5.tar.bz2''' from [http://trac.osgeo.org/geos/ http://trac.osgeo.org/geos]
* downloading directly from the command line using wget
* downloading directly from the command line using <source lang="bash" enclose="none">wget</source>
wget http://download.osgeo.org/geos/geos-3.3.5.tar.bz2
<source lang="bash">
wget http://download.osgeo.org/geos/geos-3.3.5.tar.bz2
</source>


* move to the "source-code" directory and decompress
* move to the "source-code" directory and decompress
cd /usr/local/src/
<source lang="bash">
bunzip2 geos-3.3.5.tar.bz2
cd /usr/local/src/
tar xvf  geos-3.3.5.tar
bunzip2 geos-3.3.5.tar.bz2
tar xvf  geos-3.3.5.tar
</source>


* if required, clean previous configuration & compilation  
* if required, clean previous configuration & compilation  
make distclean
<source lang="bash">
make distclean
</source>


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


* simple configure, compile and install
* simple configure, compile and install
./configure  &&  make  &&  sudo make install
<source lang="bash">
./configure  &&  make  &&  sudo make install
</source>
 
or
 
<source lang="bash">
make -j2  &&  sudo checkinstall  &&  sudo ldconfig
</source>
 
* 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">
sudo ldconfig
</source>


* ensure that '''/usr/local/lib''' is added to '''/etc/ld.so.conf''' and run '''/sbin/ldconfig''' afterwards
sudo ldconfig




Line 194: Line 267:


* download current stable version
* download current stable version
svn checkout https://svn.osgeo.org/gdal/branches/1.9/gdal gdal_stable
<source lang="bash">
svn checkout https://svn.osgeo.org/gdal/branches/1.9/gdal gdal_stable
</source>


* enter in directory '''gdal_stable'''
* enter in directory '''gdal_stable'''
cd /usr/local/src/gdal_stable
<source lang="bash">
cd /usr/local/src/gdal_stable
</source>


* optionally, update the source code
* optionally, update the source code
svn up
<source lang="bash">
svn up
</source>


* if required, clean previous configurations/compilations
* if required, clean previous configurations/compilations
make distclean
<source lang="bash">
make distclean
</source>


* a simple configuration without any parameters will detect and support various installed librairies
* a simple configuration without any parameters will detect and support various installed librairies
./configure
<source lang="bash">
./configure
</source>


* skip to the ''compile and install'' step or check below another customised configuration example
* skip to the ''compile and install'' step or check below another customised configuration example
CFLAGS="-g -Wall" LDFLAGS="-s" ./configure \
<source lang="bash">
--with-png=internal \
CFLAGS="-g -Wall" LDFLAGS="-s" ./configure \
--with-libtiff=internal \
--with-png=internal \
--with-geotiff=internal \
--with-libtiff=internal \
--with-jpeg=internal \
--with-geotiff=internal \
--with-gif=internal \
--with-jpeg=internal \
--with-ecw=yes \
--with-gif=internal \
--with-expat=yes \
--with-ecw=yes \
--with-expat-inc=/usr/include/ \
--with-expat=yes \
--with-expat-lib=/usr/lib \
--with-expat-inc=/usr/include/ \
--with-sqlite3=yes \
--with-expat-lib=/usr/lib \
--with-geos=yes \
--with-sqlite3=yes \
--with-python \
--with-geos=yes \
--with-libz=internal \
--with-python \
--with-netcdf \
--with-libz=internal \
--with-sqlite \
--with-netcdf \
--with-threads=yes \
--with-sqlite \
--without-grass  \
--with-threads=yes \
--without-ogdi \
--without-grass  \
--with-pg=/usr/bin/pg_config \
--without-ogdi \
--with-xerces=yes
--with-pg=/usr/bin/pg_config \
--with-xerces=yes
</source>


* compile, install & ldconfig
* compile, install & ldconfig
make -j2  &&  sudo make install  &&  sudo ldconfig
<source lang="bash">
make -j2  &&  sudo make install  &&  sudo ldconfig
</source>


* alternatively,  ''checkinstall''  can be used instead of  ''make install''. A deb package will be created and installed (which can be easily uninstalled)
or
make -j2  &&  sudo checkinstall  &&  sudo ldconfig
 
<source lang="bash">
make -j2  &&  sudo checkinstall  &&  sudo ldconfig
</source>




Line 246: Line 336:


* get current state of the 6.4.x release branch version (stable)
* get 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>
<source lang="bash">
svn co https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4 grass64_release
</source>


To download under development versions use:
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.'')
* 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.'')
<source lang="bash">svn checkout https://svn.osgeo.org/grass/grass/branches/develbranch_6 grass6_devel</source>
<source lang="bash">
svn checkout https://svn.osgeo.org/grass/grass/branches/develbranch_6 grass6_devel
</source>


* for GRASS 7
* for GRASS 7
<source lang="bash">svn checkout https://svn.osgeo.org/grass/grass/trunk grass_trunk</source>
<source lang="bash">
svn checkout https://svn.osgeo.org/grass/grass/trunk grass_trunk
</source>


* for subsequent updates execute:
* for subsequent updates execute:
<source lang="bash">svn up</source>
<source lang="bash">
svn up
</source>


''' Configure, Compile and Install'''
''' Configure, Compile and Install'''


* if required, clean previous configuration & compilation (not needed the first time)
* if required, clean previous configuration & compilation (not needed the first time)
<source lang="bash">make distclean</source>
<source lang="bash">
make distclean
</source>


* example configuration (which can/should be adjusted according to specific needs):
* example configuration (which can/should be adjusted according to specific needs):


<source lang="bash">
<source lang="bash">
./configure \
./configure \
--enable-largefile=yes \
--enable-largefile=yes \
--with-nls \
--with-nls \
--with-cxx \
--with-cxx \
--with-proj-share=/usr/share/proj \
--with-proj-share=/usr/share/proj \
--with-geos=/usr/bin/geos-config \
--with-geos=/usr/bin/geos-config \
--with-python=yes \
--with-python=yes \
--with-wxwidgets \
--with-wxwidgets \
--with-cairo \
--with-cairo \
--with-tcltk-includes="/usr/include/tcl8.5/" \
--with-tcltk-includes="/usr/include/tcl8.5/" \
--with-opengl-libs=/usr/include/GL \
--with-opengl-libs=/usr/include/GL \
--with-motif \
--with-motif \
--with-ffmpeg=yes --with-ffmpeg-includes="/usr/include/libavcodec /usr/include/libavformat /usr/include/libswscale" \
--with-ffmpeg=yes --with-ffmpeg-includes="/usr/include/libavcodec /usr/include/libavformat /usr/include/libswscale" \
--with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
--with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
--with-postgres=yes \
--with-postgres=yes \
--with-postgresql=yes --with-postgres-includes="/usr/include/postgresql" \
--with-postgresql=yes --with-postgres-includes="/usr/include/postgresql" \
--with-sqlite=yes \
--with-sqlite=yes \
--with-mysql=yes --with-mysql-includes="/usr/include/mysql" \
--with-mysql=yes --with-mysql-includes="/usr/include/mysql" \
--with-odbc=yes
--with-odbc=yes
</source>
</source>


Note: when not using PROJ 4 from repository, replace above related line with <source lang="bash" enclose="none">--with-proj-share=/usr/local/share/proj/ \</source> (and do so likewise for GEOS)
''Note'', when not using Proj4 from the repository, replace the above related line with <source lang="bash" enclose="none">--with-proj-share=/usr/local/share/proj/ \</source> (and do so likewise for GEOS)


* compile & install
* compile & install
<source lang="bash">make -j2  &&  sudo make install  &&  sudo ldconfig</source>
<source lang="bash">
make -j2  &&  sudo make install  &&  sudo ldconfig
</source>
 
or
 
<source lang="bash">
make -j2  &&  sudo checkinstall  &&  sudo ldconfig
</source>


* alternatively, <source lang="bash" enclose="none">checkinstall</source> can be used instead of <source lang="bash" enclose="none">make install</source>. A <source lang="bash" enclose="none">deb</source> package will be created and installed (which can be easily uninstalled)
<source lang="bash">make -j2  &&  sudo checkinstall  &&  sudo ldconfig</source>


=== GDAL-GRASS-Plugin ===
=== GDAL-GRASS-Plugin ===

Revision as of 20:57, 29 December 2012

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
    


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 Quantal Quetzal (12.10)

  • 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:...):
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 \
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
    
  • 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
  • grant rwx (read-write-execute) permissions for our userid and groupid onto the directory (replace below the terms userid and groupid with a real userid):
sudo chown userid:groupid /usr/local/src
sudo chmod ug+rwx /usr/local/src

Earlier Ubuntu versions

libpnglite-dev --> libpngwriter-dev
libtiff5-dev --> libtiff4-dev
libpngwriter-dev --> libpngwriter0-dev
libcairo-dev --> libcairo2-dev
fftw3 --> libfftw3-3
fftw3-dev --> libfftw3-dev
sudo apt-get install libhdf4-alt-dev libhdf4-0-alt
 sudo apt-get install libhdf4g-dev libhdf4g-run


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

or

make -j2  &&  sudo checkinstall  &&  sudo ldconfig
  • go to the src directory
cd /usr/local/src


GEOS

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

or

make -j2  &&  sudo checkinstall  &&  sudo ldconfig
  • ensure that /usr/local/lib is added to /etc/ld.so.conf and afterwards run
sudo ldconfig


GDAL

  • 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
  • a simple configuration without any parameters will detect and support various installed librairies
./configure
  • skip to the compile and install step or check below another 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=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 -j2  &&  sudo make install  &&  sudo ldconfig

or

make -j2  &&  sudo checkinstall  &&  sudo ldconfig


GRASS GIS

Before attempting to compile GRASS, read within the INSTALL file (located in GRASS' source code root directory) section (C) titled COMPILATION NOTES for 64bit platforms.


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 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 \
--enable-largefile=yes \
--with-nls \
--with-cxx \
--with-proj-share=/usr/share/proj \
--with-geos=/usr/bin/geos-config \
--with-python=yes \
--with-wxwidgets \
--with-cairo \
--with-tcltk-includes="/usr/include/tcl8.5/" \
--with-opengl-libs=/usr/include/GL \
--with-motif \
--with-ffmpeg=yes --with-ffmpeg-includes="/usr/include/libavcodec /usr/include/libavformat /usr/include/libswscale" \
--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=yes

Note, when not using Proj4 from the repository, replace the above related line with --with-proj-share=/usr/local/share/proj/ \ (and do so likewise for GEOS)

  • 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
  • create /etc/ld.so.conf.d/grass6.conf or add in /etc/ld.so.conf the GRASS library path, i.e. /usr/local/src/grass64_release/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=/geo/osgeo/src/grass64_release/dist.x86_64-unknown-linux-gnu/ \
--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
--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.0svn (directory, 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 (directory, 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