3

I have the problem with the enabling extension SFCGAL.

CREATE EXTENSION postgis_sfcgal;

doesn't work for me even I have the PostGIS v2.2.

When I do that, it throws an error

ERROR: could not open extension control file /Applications/Postgres.app/Contents/Versions/9.5/share/postgresql/extension/postgis_sfcgal.control: No such file or directory.

  • Did you build from source or is this from a package? – John Powell Oct 25 '15 at 15:03
  • Not all distributions of PostGIS 2.2. carry postgis_sfcgal. To my knowledge I think windows is the only distribution that currently does (which I am the packager of). Perhaps you can suggest postgres app folks to carry it and they will oblige if enough want it. – LR1234567 Oct 25 '15 at 19:40
  • I have probably used the package, where this extension was not included. I used v2.2 on MAC. I am trying to figure it out by using the github package. – Michael Knave Oct 26 '15 at 10:00
  • yep, on linux versions, you need to build it from source. (listed as optional : postgis.net/docs/manual-2.2/…). You can use hub.docker.com/r/cactusbone/postgres-postgis-sfcgal if you're on docker. although i've not added postgres 9.5 on it. – Charly Koza Oct 26 '15 at 10:09
  • Might zimmi.cz/posts/2015/… be of any help? – Michal Zimmermann Mar 10 '16 at 7:12
3

It seems the PostGIS version you are using does not provide SFCGAL support.

I managed to compile PostGIS 2.2.2 with SFCGAL 1.3.0 support for PostgreSQL 9.5 using following script, which is based on this. You need to get the latest CGAL library first using the PPA given on this webpage. I was facing some 'missing keys errors' on the way I was able to resove using y-ppa-manager.

Version overview:

Unbuntu Trusty Tar 14.04 LTS
PostGIS 2.2.2
GEOS 3.5.0
PostgreSQL 9.5
SFCGAL 1.3.0
CGAL 4.7.2 

The script is just what I copied toghter during the process, you might have to adapt some parts.

#!/bin/bash
# install cgal ----------------------------------------------------------------

sudo sh -c "echo 'deb http://debian.cgal.org stable main' >> /etc/apt/sources.list"
sudo sh -c "echo 'deb-src http://debian.cgal.org stable main' >> /etc/apt/sources.list"

# install y-ppa-manager to get missing keys
sudo add-apt-repository ppa:webupd8team/y-ppa-manager

# install geos 3.5 ------------------------------------------------------------
cd ~
wget http://download.osgeo.org/geos/geos-3.5.0.tar.bz2
bunzip2 geos-3.5.0.tar.bz2
tar xvf geos-3.5.0.tar
cd geos-3.5.0
./configure
make && sudo make install


# add postgresql official repository to apt
# apt-get update
# echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" >> /etc/apt/sources.list
# wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# apt-get update

# install required libraries
apt-get install autoconf build-essential cmake docbook-mathml docbook-xsl libboost-dev libboost-thread-dev libboost-filesystem-dev libboost-system-dev libboost-iostreams-dev libboost-program-options-dev libboost-timer-dev libcunit1-dev libgdal-dev libgeos++-dev libgeotiff-dev libgmp-dev libjson0-dev libjson-c-dev liblas-dev libmpfr-dev libopenscenegraph-dev libpq-dev libproj-dev libxml2-dev xsltproc git build-essential wget

# this is done above
# apt-get install libcgal-dev

# install postgresql-9.5 server
apt-get install postgresql-9.5 postgresql-9.5-dev postgresql-server-dev-9.5

# build sfcgal from source
wget https://github.com/Oslandia/SFCGAL/archive/v1.3.0.tar.gz
tar zxvf v1.3.0.tar.gz
cd SFCGAL-1.3.0 &&  cmake . && make  && make install
cd ..

# build postgis from source
wget http://postgis.net/stuff/postgis-2.2.2dev.tar.gz
tar zxvf postgis-2.2.2dev.tar.gz
cd postgis-2.2.2dev
./configure --with-sfcgal=/usr/local/bin/sfcgal-config
make && make install
cd ..

# probably uneeded ------------------------------------------------------------
# chmod 777 /usr/local/lib/libSFCGAL.*
# cp /usr/local/lib/libSFCGAL.* /usr/lib/postgresql/9.5/lib
# ldconfig -v | grep -i sfcgal 

sudo -i -u postgres
psql -c "create database postgis_test;"
psql postgis_test -c "create extension postgis;"
psql postgis_test -c "create extension postgis_sfcgal;"
psql postgis_test -c "select postgis_sfcgal_version();"
  • This answer was useful for me. I made a blog post with some updated command for Ubuntu 18.04 and postgresql 10: nobohan.be/2019/09/13/… – juminet Sep 13 at 13:16
2

I installed postgis-2.2 under Ubuntu 16.04 alpha2 using apt-get on default repositories. And then

CREATE EXTENSION postgis_sfcgal;

works out of the box.

test=# create extension postgis_sfcgal;
CREATE EXTENSION
test=# select postgis_sfcgal_version();
 postgis_sfcgal_version 
------------------------
 1.2.2
(1 row)
0

I installed via packages on Windows7 on a 64 bit laptop. The sequence was:

  1. postgresql 9.6 BigSQL distribution
  2. postgis 2.3 BigSQL distribution
  3. sfcgal 2.2.4

The initial installation of sfcgal did not result in it being listed as an available postgresql extension. This appeared to be due to different hard coded pathnames used respectively by the BigSQL and sfcgal installers.

This was fixed by manually moving the sfcgal files within the PostgreSQL directory structure, so that sfcgal then appeared as an available extension. I tried a few places before it worked, but this was back in July and I can't recall which location was successful. I think it was: PostgreSQL/pg96/share/postgresql/lib

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.