Problems with $libdir on PostgreSQL
Asked Answered
W

2

12

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.

Whitehall answered 28/8, 2009 at 19:51 Comment(1)
This should work. Perhaps you are mixing different installations?Abcoulomb
G
6

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.

Guttle answered 20/6, 2011 at 8:27 Comment(1)
Nicely done, I did ln -s /Library/PostgreSQL/9.1/lib/postgis-1.5.so /Library/PostgreSQL/9.1/lib/postgresql/postgis-1.5 for my installationBelga
E
1

Edited out original reply for it was wrong

Now that I've looked up postgresql code I have to admit that this string is supposed to be expanded since 2001 ;-). The expansion is very limited though. It only expands $libdir followed by directory separator. Still, your output indicates that the string wasn't expanded, because the reported string here is the string actually used for loading library.

That means that substitution failed. Looking at it closer I can see that the expansion only succeeds if target file actually exists. Assuming your directory separator is / and DLSUFFIX is .so and the file /usr/local/pgsql/lib/liblwgeom.so actually exists, I have no faintest clue why the hell it fails ;-)

Ehling answered 31/8, 2009 at 13:46 Comment(2)
Why do you say that? This appears to be completely standard usage.Whitehall
Joe, your question took me by surprise, I've changed the answer ;-)Ehling

© 2022 - 2024 — McMap. All rights reserved.