Problems with $libdir on PostgreSQL

Joe Germuska picture Joe Germuska · Aug 28, 2009 · Viewed 16.5k times · Source

In short, my question is "why doesn't $libdir work on my PSQL installation."

CREATE FUNCTION st_box2d_in(cstring) RETURNS box2d
    AS '$libdir/liblwgeom', 'BOX2DFLOAT4_in'
    LANGUAGE c IMMUTABLE STRICT;

yields an error

could not access file "$libdir/liblwgeom": No such file or directory

while

CREATE FUNCTION st_box2d_in(cstring) RETURNS box2d
    AS '/usr/local/pgsql/lib/liblwgeom', 'BOX2DFLOAT4_in'
    LANGUAGE c IMMUTABLE STRICT;

works correctly.

The output of

% pg_config --pkglibdir
/usr/local/pgsql/lib

appears to be correct.

Answer

Johan.l picture Johan.l · Jun 20, 2011

I struggled with this error as well. I solved it by linking in the PostGIS lib manually to the liblwgeom file, like this:

ln -s /usr/lib/postgis/1.5.1/postgres/8.4/lib/postgis-1.5.so 
    /usr/lib/postgresql/8.4/lib/liblwgeom

I have no idea why PostGIS installs itself in the 'wrong' directory, or why PostgreSQL looks for a file named liblwgeom when it seems to be the same file which PostGIS calls postgis-1.5.so

All I know is that that seems to have fixed my problem.