Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have spent the past few days of my life trying to figure out how to get postgis to function properly with a non-standard directory installation of postgres 9.3, but have been unable to resolve the following obnoxious errors:

ERROR:  could not load library "/pginstall/postgresql93/lib/postgis-2.1.so": libgeos_c.so.1: cannot open shared object file: No such file or directory

********** Error **********

ERROR: could not load library "/pginstall/postgresql93/lib/postgis-2.1.so": libgeos_c.so.1: cannot open shared object file: No such file or directory
SQL state: 58P01

I installed geos,gdal and postgres into contained directories in order to be able to update components without needing to manually find individual files and remove them.

Thus my libraries would be located in the following installation directories:


All other dependencies are installed using standard apt packages and I am using the standard build-essential package.

I tried setting various environment variables

    export LD_LIBRARY_PATH=/pginstall/geos34/lib:/pginstall/gdal110/lib
    export LDFLAGS="-Wl,-rpath,/pginstall/geos34/lib/,-rpath,/pginstall/postgresql93/lib,-rpath,/pginstall/gdal110/lib"
    export LDFLAGS="-Wl,-L,/pginstall/geos34/lib,-L,/pginstall/postgresql93/lib,-L,/pginstall/gdal110/lib"
    export LDFLAGS="-L/pginstall/geos34/lib -Wl,-rpath,/pginstall/geos34/lib"
    export LDFLAGS="-Wl,-rpath,/pginstall/geos34/lib/,-rpath,/pginstall/gdal110/lib"

But they all failed to work with the configuration below

./configure \
    --prefix=/pginstall/postgresql93 \
    --with-pgconfig=/pginstall/postgresql93/bin/pg_config \
    --with-geosconfig=/pginstall/geos34/bin/geos-config \
    --with-gdalconfig=/pginstall/gdal110/bin/gdal-config \
    --with-topology \

I did manage to get this woking by adding the LD_LIBRARY_PATH variable to my upstart configuration for postgres --but this is a crude hack and is clearly not suitable for any kind of pre-production or production environment. I don't want to go the ldconfig route either as that requires root access.

I can verify that this issue is that the postgis configure process is ignoring my direct commands to add the paths to the binaries, by running the following command:

chrpath -l /pginstall/postgis/postgis-2.1.0SVN/postgis/postgis-2.1.so

which yields


The LDFLAG commands work when compiling GDAL with GEOS and Postgres, so I believe this is a postgis specific issue.

I have no idea what else I can do as I am not a c compiler expert, nor should I need to be to perform this simple task on the OS upon which postgis was developed!

One would assume that postgis should know where the libraries are given that I set them explicitly in the configure step and after concurrently setting LD_LIBRARY_PATH and LD_FLAGS. This is pretty depressing. What more should one need to specify?

Does anyone know of a simple way to fix this issue?

As a side note I am glad I program in Java, as properly building from source in C basically seems to follow the steps below:

1) Hope configure/make/make install just miraculously work

2) Upon inevitable failure, set random environment variables that each have 6.022E^23 contradictory explanations for its function on the internet for each operating system --and are sourced from.

3) Upon inevitable failure, Sacrifice a macbook to the gods of C

4) Consign yourself to your grim fate and download a mostly broken and ridiculously out-of-date package from apt instead.

share|improve this question

1 Answer 1

Linux uses the list of directories in the file /etc/ld.so.conf to know where to look for shared objects.

Add your /pginstall directories to that file.

The LD_LIBRARY_CONFIG symbol does not work for services like postgres since that symbol is not used when a program does not have a shell (like bash) starting it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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