Scientia Plus Conscientia

Thoughts on Science and Nature

Software and install notes

These are my notes for installing from source the software tools I use most often. The instructions are given in order to satisfy dependencies, for openSUSE Leap 42.2 on a AMD 64-bit machine. Note that although I try to write everything as carefully as possible, unintended inconsistencies and errors always manage to find their way into these notes. Use with caution!

Prerequisites:
gcc, gcc++, gcc-fortran, make, cmake, hdf5, libtiff, libjpeg, libpng, gd, libcairo, freetype, ncurses, blas, readline, libxml, libxml2, numpy, flex, python-sip, libusb, giflib, libwebp, libcurl, bison, pango, wxWidgets, ghostscript, sqlite, qt, libwebkit, tcl, tk, motif, libcerf

Also install the devel files. Using zypper for this is practical.

General procedure:
Open a terminal
su root  # change to root user
cd /usr/local/src  # change to a suitable build directory

Then, for every package “foo” download the tarball (foo.tar.gz) from each site:
wget foo.tar.gz

then uncompress and untar:
tar -xvf foo.tar.gz

change to the directory in question:
cd foo/

then, proceed as indicated.

Install recipes:

———————————————————–
NetCDF (http://www.unidata.ucar.edu/software/netcdf/)

./configure CC=gcc  FC=gfortran F90=gfortran F77=gfortran CPPFLAGS=-DpgiFortran --with-pic
# convenient to install F90 support
# –with-pic is mandatory in 64 bit systems (GDAL compatibility)

make
make check
make install

———————————————————–
GEOS  (http://trac.osgeo.org/geos/)

./configure
make
make install

———————————————————–
PROJ  (https://github.com/OSGeo/proj.4/releases)

# once downloaded and untarred, change directory
cd /usr/local/proj-4-X.X.X/

# then make new directory “build”
mkdir build

# change directory
cd /build

ccmake ..
make
make install

———————————————————–
libgeotiff (http://download.osgeo.org/geotiff/libgeotiff/)

./configure
make
make install

———————————————————–
FFTW  (http://www.fftw.org/)

./configure --with-pic
make
make install

———————————————————–
ImageMagick

(go to http://git.imagemagick.org/repos/ImageMagick/tree/master and then choose a suitable distribution, like the most recent release)

./configure --with-perl --with-fftw # FFTW must have been compiled with -with-pic
make
make check
make install

———————————————————–
gnuplot  (http://www.gnuplot.info/)
A lightweight but powerful graphing utility. It can be used from the command line or embedded in scripts (as I usually do from Perl). gnuplot is stable, reliable and easy to use. You can even use it to analyze data. There are plenty of resources on gnuplot out there.

./configure
make
make check
make install

———————————————————–
GSL – GNU Scientific Library (http://www.gnu.org/software/gsl/)

./configure
make
make check
make install

——————————————————————————-
Spatialite (http://www.gaia-gis.it/gaia-sins/)

# requires SQLite, with devel packages

# begin with freexl (https://www.gaia-gis.it/fossil/freexl/index)
./configure
make
make install

# then continue with
# libspatialite (https://www.gaia-gis.it/fossil/libspatialite/index)
./configure --enable-libxml2
make
make install

# and then
# readosm (https://www.gaia-gis.it/fossil/readosm/index)
# spatialite-tools (https://www.gaia-gis.it/fossil/spatialite-tools/index)
# libgaiagraphics (https://www.gaia-gis.it/fossil/libgaiagraphics/index)
# spatialite_gui (https://www.gaia-gis.it/fossil/spatialite_gui/index)
# librasterlite2 (https://www.gaia-gis.it/fossil/librasterlite2/index)
# for all these do:

./configure
make
make install

——————————————————————————-
GDAL (http://www.gdal.org)
A powerful library for processing raster data formats. It comes with a suite of useful programs to perform basic routine tasks like projections and format translations. The related library OGR allows analogous tasks for vector data.

./configure  --with-netcdf=/usr/local --with-png=/usr/lib --with-libtiff=internal --with-geotiff=/usr/local --with-jpeg=/usr/lib --with-geos=/usr/local/bin/geos-config --with-python --with-odbc --without-libtool  --with-spatialite=/usr/local
make
make install

# Notes:
# To install the perl module Geo::GDAL just follow instructions here

# To install the JPEG2000 driver, follow the instructions here, note however that the link to the modified JasPer library is not the one given in the page, but this one: http://download.osgeo.org/gdal/jasper-1.900.1.uuid.tar.gz

——————————————————————————-
GPSBABEL (http://www.gpsbabel.org/)

# Note that if you do not install the libusb library
# gpsbabel will compile without complaining but it
# will not be able to download gps data from a usb.
# Install libusb, pay attention to include the the libusb-config package

./configure
make
make install

# Still needs to be investigated how to make it work with Garmin USB in OpenSUSE
# when one is not logged as root. According to the website, one should do:
# To make it work I normally execute gpsbabel as root
# having previously disabled the garmin_gps kernel module:
rmmod garmin_gps

——————————————————————————-
QGIS (http://qgis.org)

# pay attention to the many requirements (with devel files):
# libwebkit, python-qt, qwt, libspatialindex, scintilla, qtwebkit, etc

# once downloaded and untarred, change directory
cd /usr/local/qgis-X.X.X/

# then make new directory “build”
mkdir build

# change directory
cd /build

ccmake ..
make
make install

——————————————————————————-
GRASS (https://grass.osgeo.org/)

./configure --enable-shared --with-odbc --with-fftw --with-readline --with-curses --with-proj-share=/usr/local/share/proj --enable-largefile --with-motif --with-freetype --with-freetype-includes=/usr/include/freetype2 --with-sqlite --enable-64bit --with-geos --with-python --with-netcdf
make
make install

———————————————————–
GMT (http://gmt.soest.hawaii.edu)
# these are steps for version 5
# adapted from the official instructions (http://gmt.soest.hawaii.edu/projects/gmt/wiki/BuildingGMT)

– get the GMT tree
svn checkout svn://gmtserver.soest.hawaii.edu/gmt5/trunk gmt-dev

– get and untar GSHHG coastlines (ftp://ftp.soest.hawaii.edu/gshhg)
– get and untar country polygons (ftp://ftp.soest.hawaii.edu/dcw)
– copy cmake/ConfigUserTemplate.cmake to cmake/ConfigUser.cmake
– edit the file:

# Set path to GSHHG Shoreline Database [auto]:
set (GSHHG_ROOT "/usr/local/src/gshhg-gmt-ncX-X.X.X")

# Copy GSHHG files to $/coast [FALSE]:
set (COPY_GSHHG TRUE)

# Set path to DCW Digital Chart of the World for GMT [auto]:
set (DCW_ROOT "/usr/local/src/dcw-gmt-X.X.X")

# Copy DCW files to $/dcw [FALSE]:
set (COPY_DCW TRUE)

# Build and install GMT:

cd gmt-dev
mkdir build
cd build
cmake ..
make
make install

———————————————————–
Perl
Perl is a versatile and very powerful general-purpose programming language. It is easy to learn and use, and is very well suited for all tasks a geoscientist does. These days, most people in the scientific community prefer Python though. Perl has existed since 1987 and people have contributed a large number of useful modules for almost every imaginable purpose. You can find them in the impressive Comprehensive Perl Archive Network – CPAN. Among them is the fantastic and flexible Perl Data Language – PDL, the number crunching Perl extension akin to NumPy, Matlab or IDL.
Perl comes with all Linux systems, and it is best managed using the package manager, zypper. To install modules use CPAN, from the command line.

I usually install the last available Perl version in a separate folder, in order to not to upset the system’s Perl:

/usr/local/perls/perl_X.X.X

as described here. I then make symbolic links of the content of the bin directory in the /usr/local/bin:

ln -s /usr/local/perls/perl_X.X.X/bin/* /usr/local/bin

———————————————————–
R
R is a powerful environment for statistical data analysis and graphics. The learning curve might be a bit steep for those not used to programming, but there exists an enormous amount of freely available quality material in the internet. An Introduction to R is a useful starting point.

./configure
make
make install

To install packages proceed from the command line with install.packages() command. See documentation.

———————————————————–
LaTeX

LaTeX is a tool for making pretty documents, particularly those that include mathematical expressions. It is perfect for writing scientific papers, reports and books. It has a long history and there are plenty of resources in the internet. The initial learning curve might be a bit steep but the results are really worth the efforts.
Warning: if you try LaTeX once you might not want to use a “normal” word processor again!

I prefer to install LaTeX using the zypper package manager. In Linux, it is usually TeXLive.

———————————————————–
Maxima

A computer algebra system. Handy when you want to check your tedious derivations by hand.

# requires lisp

./configure
make
make install

———————————————————–
Below are the instructions for installing PostgreSQL and PostGIS. I have since a while ago replaced them with SQLite/Spatialite in my workflow. I nevertheless keep the notes because the installation procedure can be involved.

———————————————————–
PostgreSQL (http://www.postgresql.org)

./configure --with-perl --with-python
gmake
useradd postgres -p postgres # simple password: postgres
# make sure that the home directory for user
# postgres is where you put the data
chown -R postgres /usr/local/src/postgresql-X.X.X
su postgres
gmake check
exit (su root)
gmake install

# add to /etc/bash.bashrc.local:
export PATH=$PATH:/usr/local/pgsql/bin
# add to /etc/bash.bashrc.local:
export MANPATH=$MANPATH:/usr/local/pgsql/man
# add to /etc/ld.so.conf
/usr/local/pgsql/lib64

then continue:

ldconfig
mkdir /where/your/pgdata/istobelocated # this should be the default directory
chown postgres /where/your/pgdata/istobelocated
su posgtres
initdb -D /where/your/pgdata/istobelocated
postmaster -D /where/your/pgdata/istobelocated
su root
cp contrib/start-scripts/linux /etc/init.d/postgresql
make /etc/init.d/postgresql executable

# as root, activate postgresql in runtime levels 3 and 5
chkconfig --level 35 postgresql on

# leave configured and built in order to follow with PostGIS
# you might want to keep the configured /src directory to eventually uninstall later

———————————————————–
PostGIS (http://www.postgis.org)
Spatial module for PostgreSQL, which transforms your database into a powerful GIS. The combination of PostGIS/PostgreSQL with Quantum GIS makes up a powerful and versatile environment. QGIS can, for example, digitize directly in the PostGIS enabled PostgreSQL database, from which you can make all sorts of calculations and processing using scripts in SQL or, as I do, in Perl.

# note that PostGIS 2 requires GDAL, see below for notes
# at present I am compiling without raster support
# because of endless troubles with “GDALAllRegister”

mv postgis-X.X.X/ postgresql-X.X.X/contrib/postgis-X.X.X/
./configure --without-raster
make
make install
su postgres
createdb test
# createlang plpgsql test
psql -f postgis/postgis.sql -d test
psql -f spatial_ref_sys.sql -d test

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: