PostGIS – Cannot Create Extension postgis_raster on CentOS 7.6

postgis

I am using CentOS 7.6 at work. One one server I have PostgreSQL 12 and PostGIS 3 installed from the pgdg12 repo. This is working fine for vector data, but now I would like to use it for raster data as well, but when I run

-bash-4.2[Kartdata]$ psql <database> -c "create extension postgis_raster;"

I get

ERROR: could not load library "/usr/pgsql-12/lib/postgis_raster-3.so": /usr/gdal30/lib/libgdal.so.26: undefined symbol: GEOSMakeValid_r

I have been checking that PostgreSQL, PostGIS, GEOS and GDAL all are the newest versions, but except that PostgreSQL and PostGIS both are from the pgdg12 repo but GEOS and GDAL are from pgdg10 (I have tried to install it from pgdg12, but CentOS is still using pgdg10) everything seems perfect.

Any other ideas where I could look?

bash-4.2[<>]# ls -l /usr/pgsql-12/lib/postgis*
lrwxrwxrwx 1 root root      30 Nov  5 08:28 /usr/pgsql-12/lib/postgis-2.5.so -> /usr/pgsql-12/lib/postgis-3.so
-rwxr-xr-x 1 root root 1067904 Sep 30 12:14 /usr/pgsql-12/lib/postgis-3.so
lrwxrwxrwx 1 root root      37 Nov  5 08:28 /usr/pgsql-12/lib/postgis_raster-2.5.so -> /usr/pgsql-12/lib/postgis_raster-3.so
-rwxr-xr-x 1 root root  862368 Sep 30 12:14 /usr/pgsql-12/lib/postgis_raster-3.so
lrwxrwxrwx 1 root root      39 Nov  5 08:28 /usr/pgsql-12/lib/postgis_topology-2.5.so -> /usr/pgsql-12/lib/postgis_topology-3.so
-rwxr-xr-x 1 root root  552168 Sep 30 12:14 /usr/pgsql-12/lib/postgis_topology-3.so


bash-4.2[<>]# ls -l /usr/gdal30/lib/
total 20664
drwxr-xr-x 2 root root        6 Nov  4 19:34 gdalplugins
lrwxrwxrwx 1 root root       17 Nov  5 08:28 libgdal.so.26 -> libgdal.so.26.0.2
-rwxr-xr-x 1 root root 21156328 Nov  4 19:35 libgdal.so.26.0.2

Best Answer

In my case, yum had several enabled pgdg repositories and the gdal lib was installed from a different pg version as Postgis. After reducing the enabled pgdg repositories to just one (the version of interest) and reinstall the effected packages, I was able to use pg with Postgis again.

More details see https://stackoverflow.com/a/60552946/10864551

Based on this I did

find /usr -name libgeos\*
find /usr -name libgdal\*

These two commands showed me that there were a few different versions of both libraries on my system.

Then I could use

rpm -qf <filename with path>

to show me which package provided each of the libraries and do the needed

yum remove <package>

Which in the end gave me a system where I could install the raster extension.

Related Question