I‘ve recently needed a spatial database for storing a large amount of point data. I first thought about PostGIS but was turned off by its Client-Server-Architecture which seemed a too big overhead for my small task. On the other hand, I already had a SQLite database running and was thus familiar with its lightweight approach. Thus I decided to try out SpatiaLite, which, like PostGIS, supports the OpenGIS specifications.
Installing all the latest versions of the SpatiaLite family on Ubuntu 12.04 turned out to be a bit tedious though. As of today, these are SpatiaLite 4.0.0 and SpatiaLite GUI 1.6. I had to compile everything from source and was often thrown back just to learn that I need to install all the *-dev versions of the needed C libraries as well.
There actually are packaged versions of SpatiaLite and SpatiaLite GUI in the package system of Ubuntu, but they are often a version or more behind the actual version.
Therefore this post will give an easy, copy-paste style how-to for compiling SpatiaLite and its GUI with all the dependencies.
SpatiaLite 4
First you need to have all the dev versions of the libraries SpatiaLite depends on:
sudo apt-get update sudo apt-get install libsqlite3-dev sudo apt-get install libproj-dev sudo apt-get install libgeos-dev
Although you might not need it, you should install FreeXL since it is definitely needed by the GUI, and I ran into problems when I chose not to install it in the first place.
wget http://www.gaia-gis.it/gaia-sins/freexl-sources/freexl-1.0.0g.tar.gz tar -xvzf freexl-1.0.0e.tar.gz cd freexl-1.0.0e/ ./configure make -j8 sudo make install-strip
Then, to install the main package (maybe you have to add `–disable-freexl` after `./configure` if this doesn’t work, it used to work for me, see comments below):
wget http://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-4.0.0.tar.gz tar -xvzf libspatialite-4.0.0.tar.gz cd libspatialite-4.0.0/ ./configure --with-geosconfig=/usr/bin/geos-config make -j8 sudo make install-strip
You should also install the command line utility (similar to the SQLite utility) and other helpful tools. In my case, I didn’t need OSM support, so I disabled it.
wget http://www.gaia-gis.it/gaia-sins/spatialite-tools-sources/spatialite-tools-4.0.0.tar.gz tar -xvzf spatialite-tools-4.0.0.tar.gz cd spatialite-tools-4.0.0/ ./configure --disable-readosm make -j8 sudo make install-strip
In order for everything to work, you need to register the path to the binaries like this: Open up ld.so.conf with a text editor
sudo vim /etc/ld.so.conf
and add
/usr/local/lib
at the end of that file. After that, refresh:
sudo ldconfig
If you don’t want the GUI, you’re done and can invoke the CLI via
spatialite test.db
If you want the GUI, follow these steps…
SpatiaLite GUI 1.6
Again, you need to install dev versions of required libraries:
sudo apt-get install libjpeg-dev sudo apt-get install libgeotiff-dev sudo apt-get install libpng-dev sudo apt-get install libcairo2-dev sudo apt-get install libwxgtk2.8-dev
You really need FreeXL for the GUI, so if you haven’t installed it yet, you might just as well start from scratch. Apart from that, you’ll need libgaiagraphics
wget http://www.gaia-gis.it/gaia-sins/libgaiagraphics-0.4b.tar.gz tar -xvzf libgaiagraphics-0.4b.tar.gz cd libgaiagraphics-0.4b/ ./configure make -j8 sudo make install-strip
Finally, you can install the GUI with
wget http://www.gaia-gis.it/gaia-sins/spatialite_gui-1.6.0.tar.gz tar -xvzf spatialite_gui-1.6.0.tar.gz cd spatialite_gui-1.6.0/ ./configure make -j8 sudo make install-strip
There you go!
Pingback: Installing on Linux – SpatiaLite Talk