0

I am working on a CentOS 7 server with PostGIS 3.2 installed. When I try to create the PostGIS extension using CREATE EXTENSION postgis;, I get the following error:

ERROR:  could not load library "/usr/pgsql-15/lib/postgis-3.so": libgeos_c.so.1: cannot open shared object file: No such file or directory

Note that /usr/pgsql-15/lib/postgis-3.so exists.

Both paths that lead to postgis-3.so AND libgeos_c.so.1 are in the LD_LIBRARY_PATH.

Here's the output of echo $LD_LIBRARY_PATH:

/usr/pgsql-15/lib:/usr/local/lib:

ldd /usr/pgsql-15/lib/postgis-3.so gives:

linux-vdso.so.1 =>  (0x00007ffc309dd000)
libm.so.6 => /lib64/libm.so.6 (0x00002b0c9c9b5000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00002b0c9ccb7000)
libgeos_c.so.1 => /usr/local/lib/libgeos_c.so.1 (0x00002b0c9cfbf000)
libproj.so.12 => /usr/local/lib/libproj.so.12 (0x00002b0c9d1f1000)
libxml2.so.2 => /lib64/libxml2.so.2 (0x00002b0c9d45a000)
libz.so.1 => /lib64/libz.so.1 (0x00002b0c9d7c4000)
libdl.so.2 => /lib64/libdl.so.2 (0x00002b0c9d9da000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002b0c9dbde000)
libc.so.6 => /lib64/libc.so.6 (0x00002b0c9ddf4000)
/lib64/ld-linux-x86-64.so.2 (0x00002b0c9c471000)
libgeos-3.6.2.so => /usr/local/lib/libgeos-3.6.2.so (0x00002b0c9e1c2000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002b0c9e570000)
liblzma.so.5 => /lib64/liblzma.so.5 (0x00002b0c9e78c000)

My PostgreSQL server is started by systemd using

systemctl start postgresql-15

If I look for the environment variable LD_LIBRARY_PATH in the output of cat /proc/12345/environ | xargs -0 -n 1 echo (where 12345 is the process ID of the postmaster process), it is not there.

How can I create the PostGIS extension?

1 Answer 1

1

You didn't set the LD_LIBRARY_PATH environment variable in the environment of the PostgreSQL database server. Since you start PostgreSQL via systemd, you have to edit the service file:

sudo systemctl edit postgresql-15

That launches an editor, into which you write:

[Service]
Environment='LD_LIBRARY_PATH=/usr/pgsql-15/lib:/usr/local/lib'

Restart PostgreSQL, and the server should have the variable set in its environment.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.