Why can't I do CREATE EXTENSION postgis_sfcgal
PostGIS 2.2.0 came out this month, and the SFCGAL extension that offers advanced 3D and volumetric support, in addition to some extended 2D functions like
ST_ApproximateMedialAxis became a standard PostgreSQL extension
and seems to be a fairly popular extension.
I've seen several reports on GIS Stack Exchange of people trying to install PostGIS SFCGAL and getting things such as
ERROR: could not open extension control file /Applications/Postgres.app/Contents/Versions/9.5/share/postgresql/extension/postgis_sfcgal.control
as in this question: SFCGAL in PostGIS problem.
There are two main causes for this:
CREATE EXTENSION postgis_sfcgal;syntax is new in PostGIS 2.2. Although SFCGAL was available in PostGIS 2.1, you needed to use the sfcgal.sql script in contrib to install it. So if you have PostGIS 2.1, you definitely can't use the CREATE EXTENSION syntax.
postgis_sfcgal is not a default built extension when you build PostGIS. There are 3 prequisites to get the extension during compile:
a. Need Boost, CGAL, and SFCGAL.
SFCGAL is compiled with CMake similar to pgRouting. Note that Boost and CGAL are also prequisites of pgRouting, so you are almost there if you have pgRouting.
SFCGAL is a relatively thin wrapper for CGAL to allow CGAL functions to be used with SQL/MM 2D/3D types.
b. You need to have in your PostGIS configure script:
--with-sfcgal=/path/to/sfcgal-config as noted in Configuration
If you are getting PostGIS from a package distribution, be warned that few packagers that offer PostGIS 2.2 have postgis_sfcgal.
I'm not even sure if any beyond the Windows application PostGIS 2.2. bundle stackbuilder package have it.
If you want it and your package maintainer doesn't carry it, perhaps you can encourage them to.
As a related warning:
Do Not install postgis_sfcgal (of PostGIS 2.2) in a PostGIS 2.1 or lower database
Although the PostgreSQL extension system will allow it, do not try to use postgis_sfcgal packaged with PostGIS 2.2 with PostGIS 2.1. The combination will be disastrous because you will end up with 2 PostGIS backends fighting each other.