postgrespro/pgsphere

Can't link correctly to healpix library

Closed this issue · 5 comments

I'm having a very difficult time getting the pgsphere extension to link properly against an installed healpix library.

ppdb=# CREATE EXTENSION pg_sphere;
ERROR:  could not load library "/usr/lib/postgresql/16/lib/pg_sphere.so": /usr/lib/postgresql/16/lib/pg_sphere.so: undefined symbol: _ZTI11PlanckError

The healpix library seems to contain this symbol:

nm -D libhealpix_cxx.so.4 | grep PlanckError
0000000000042be0 T _ZN11PlanckErrorC1EPKc
0000000000042b30 T _ZN11PlanckErrorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
0000000000042be0 T _ZN11PlanckErrorC2EPKc
0000000000042b30 T _ZN11PlanckErrorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
0000000000042b10 T _ZN11PlanckErrorD0Ev
0000000000042ad0 T _ZN11PlanckErrorD1Ev
0000000000042ad0 T _ZN11PlanckErrorD2Ev
00000000000430e0 W _ZNK11PlanckError4whatEv
00000000000c2bf8 V _ZTI11PlanckError
00000000000a9768 V _ZTS11PlanckError
00000000000c2c08 V _ZTV11PlanckError

And ldd indicates that pgsphere is linked against the healpix library.

Any ideas how to debug/fix this?

Dockerfile.txt

Here is the Dockerfile.

I'm using a Citus image, but I doubt it matters.

I can try testing with the official Postgres image to rule it out if necessary...

Looks like I needed something like this:

SET dynamic_library_path TO '/usr/lib/postgresql/16/lib:/opt/healpix/lib';

Closing as fixed.

esabol commented

Did setting the LD_LIBRARY_PATH environment variable before starting PostgreSQL not work?

I imagine you could also add a file to /etc/ld.so.conf.d/ to get it to load that way.

Well, we should probably add something along these lines to the README and/or documentation.

Did setting the LD_LIBRARY_PATH environment variable before starting PostgreSQL not work?

I imagine you could also add a file to /etc/ld.so.conf.d/ to get it to load that way.

Well, we should probably add something along these lines to the README and/or documentation.

(Let me reopen this ticket so we can dialog about it.)

Yes, I ended up doing all of what you suggested, too. :)

I can provide a Dockerfile if that would be helpful.

Getting healpix -> pg_sphere -> Postgres setup properly is actually pretty tricky.

Dockerfile.txt

This is what worked for me, at least for getting the extension loading properly.

(Note that this uses a Citus Docker container and not an official Postgres one, but I do not think that matters as Citus runs as a Postgres database with an extension.)