I am unable to create the PostGIS extension on new databases in Ubuntu 14.04:

$  psql pg_testing -c "create extension postgis"
ERROR:  could not load library "/usr/lib/postgresql/9.3/lib/postgis-2.1.so": /usr/lib/liblwgeom-2.1.3.so: undefined symbol: GEOSDelaunayTriangulation

All the software was installed from the Postgres repositories:

$ dpkg -l | grep postgres
ii  libpostgresql-jdbc-java                               9.2-1002-1                                          all          Java database (JDBC) driver for PostgreSQL
ii  pgdg-keyring                                          2013.2                                              all          keyring for apt.postgresql.org
ii  postgresql                                            9.3+154.pgdg14.04+1                                 all          object-relational SQL database (supported version)
ii  postgresql-9.3                                        9.3.4-1.pgdg14.04+1                                 amd64        object-relational SQL database, version 9.3 server
ii  postgresql-9.3-dbg                                    9.3.4-1.pgdg14.04+1                                 amd64        debug symbols for postgresql-9.3
ii  postgresql-9.3-postgis-2.1                            2.1.3+dfsg-3.pgdg14.04+2                            amd64        Geographic objects support for PostgreSQL 9.3
ii  postgresql-9.3-postgis-scripts                        2.1.3+dfsg-3.pgdg14.04+2                            all          Geographic objects support for PostgreSQL 9.3 -- scripts
ii  postgresql-client                                     9.3+154.pgdg14.04+1                                 all          front-end programs for PostgreSQL (supported version)
ii  postgresql-client-9.1                                 9.1.13-1.pgdg14.04+1                                amd64        front-end programs for PostgreSQL 9.1
ii  postgresql-client-9.3                                 9.3.4-1.pgdg14.04+1                                 amd64        front-end programs for PostgreSQL 9.3
ii  postgresql-client-common                              154.pgdg14.04+1                                     all          manager for multiple PostgreSQL client versions
ii  postgresql-common                                     154.pgdg14.04+1                                     all          PostgreSQL database-cluster manager
ii  postgresql-contrib                                    9.3+154.pgdg14.04+1                                 all          additional facilities for PostgreSQL (supported version)
ii  postgresql-contrib-9.3                                9.3.4-1.pgdg14.04+1                                 amd64        additional facilities for PostgreSQL
ii  postgresql-server-dev-9.3                             9.3.4-1.pgdg14.04+1                                 amd64        development files for PostgreSQL 9.3 server-side programming

$ apt-cache policy postgresql-9.3
  Installed: 9.3.4-1.pgdg14.04+1
  Candidate: 9.3.4-1.pgdg14.04+1
  Version table:
 *** 9.3.4-1.pgdg14.04+1 0
        500 http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg/main amd64 Packages
        100 /var/lib/dpkg/status
     9.3.4-1 0
        500 http://de.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

$ apt-cache policy postgresql-9.3-postgis-2.1
  Installed: 2.1.3+dfsg-3.pgdg14.04+2
  Candidate: 2.1.3+dfsg-3.pgdg14.04+2
  Version table:
 *** 2.1.3+dfsg-3.pgdg14.04+2 0
        500 http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg/main amd64 Packages
        100 /var/lib/dpkg/status
     2.1.2+dfsg-2 0
        500 http://de.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages

And regarding GEOS:

$ dpkg -l | grep libgeos
ii  libgeos-3.4.2                                         3.4.2-4ubuntu1                                      amd64        Geometry engine for Geographic Information Systems - C++ Library
ii  libgeos-c1                                            3.4.2-4ubuntu1                                      amd64        Geometry engine for Geographic Information Systems - C Library
ii  libgeos-dev                                           3.4.2-4ubuntu1                                      amd64        Geometry engine for GIS - Development files

$ apt-cache policy libgeos-3.4.2
  Installed: 3.4.2-4ubuntu1
  Candidate: 3.4.2-4ubuntu1
  Version table:
 *** 3.4.2-4ubuntu1 0
        500 http://de.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status

My guess is that PostGIS is expecting a different version of GEOS. The question is which? And where from to install it?

Update: There are some hints of this issue being caused by an outdated version of liblwgeom. I thus removed all related packages (apt-get purge liblwgeom*) and re-installed PostGIS. This is what I have now:

$ dpkg -l | grep liblwgeom
ii  liblwgeom-2.1.3                                       2.1.3+dfsg-3.pgdg14.04+2                            amd64        PostGIS "Lightweight Geometry" library

But the problem remains.


Following the advice at the postgis-users maillist it was possible to identify the existence of outdated ligbeos libraries as the source of the problem:

$ locate libgeos_c.so

Either during the upgrade to Ubuntu 14.04, or during the removal of old libgeos packages some .so files were inadvertently left behind. The fix was then to remove them and re-link:

$ sudo rm /usr/local/lib/libgeos_c.so*
$ sudo rm /usr/local/src/geos-3.3.1/capi/.libs/libgeos_c.so*
$ sudo ldconfig
$ sudo su postgres
$ /etc/init.d/postgresql restart 
$ psql pg_testing -c "create extension postgis"

Usually, removing libraries manually in a system fully managed with the package manager is not a good idea, leading to other problems later on. In principle this will not be the case with these libraries.

  • Worked like a charm. I didn't have anything in /usr/local/src/ so I skipped that line; didn't seem to cause any issues. – Nat Mar 22 '15 at 20:27

The only way I could get POSTGis on "Trusty" was to build from Sources, here is what I used ..

sudo mkdir postgis-build

cd postgis-build

then put the script below in a shell script file

sudo nano build.sh

make it executable and run it

sudo chmod a+x build.sh

sudo wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2
sudo tar xfj geos-3.4.2.tar.bz2
cd geos-3.4.2
sudo ./configure
sudo make
sudo make install
cd ..
sudo wget http://download.osgeo.org/postgis/source/postgis-2.1.3.tar.gz
sudo tar xfz postgis-2.1.3.tar.gz
cd postgis-2.1.3
sudo ./configure
sudo make
sudo make install
sudo ldconfig
sudo make comments-install
cd ..
sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/shp2pgsql
sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/pgsql2shp
sudo ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/raster2pgsql
  • 1
    Hi Mark, this might solve the issue, but only on a temporary basis. Mixing packages compiled from sources with packages installed from the repositories will always break up things at some point. With the automatic updates, the compiled packages eventually go out of step with those installed from the repositories. – Luís de Sousa Jul 25 '14 at 7:20
  • Don't disagree at all, but nothing form sources would work ... and I guess there are still some issues .. – Mark Cupitt Jul 25 '14 at 7:35

This doesn't answer your question directly - Mapperz has probably pointed you in the right direction. But I recommend using the UbuntuGIS package(s) as they've proven to be e-a-s-y to install and all the dependencies are there.

#    UbuntuGIS package:

sudo apt-add-repository ppa:ubuntugis/ppa
sudo apt-get update

#or for bleeding edge:
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
  • The names of the repositories may be misleading. Only the unstable has packages for Ubuntu 14.04 (trusty), and can be considered as "stable". – AndreJ Jul 25 '14 at 5:07
  • I had this repository registered on Ubuntu 12.04, but it seems to have been removed during the update to 14.04. Now that I added it manually I understand why: apt is unable to reach it, returning a "404 Not Found" error. – Luís de Sousa Jul 25 '14 at 7:15
  • Note also that presently libgeos is not listed in the ubuntugis-unstable repository. – Luís de Sousa Jul 25 '14 at 7:31
  • I think it should be in the geos package, which is indeed not yet available for trusty. – AndreJ Jul 25 '14 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.