[postgis-users] PostGIS+FreeBSD 6.0 (AMD64) and Shared object "libpq.so.5" not found

Greg Troxel gdt at ir.bbn.com
Tue Mar 17 06:04:44 PDT 2009


Paul's suggestion of LD_LIBRARY_PATH should work, but for BSD shlib
linking troubles there's a cleaner, although much harder, solution.

I maintain the postgis package in pkgsrc, native to NetBSD and
Dragonfly, often used on Darwin and Solaris, and usable on FreeBSD,
OpenBSD, Linux, and assorted retrocomputing flavors like AIX - all to
warn you that I'm being a a bit normative from the pkgsrc viewpoint.
I'm also assuming an ELF world, even though I grew up on a.out.

-L is used at link time to find the shared object, but this path
information isn't used at runtime.  There are several approaches to
run-time linking, which are basically putting everything in /usr/lib,
setting LD_LIBRARY_PATH to include places where libraries live, and
using -rpath or -R to store run-time search paths in the binary.

Linux seems to use a mix of 98% /usr/lib and 2% cope via
LD_LIBRARY_PATH, and probably as a result autoconf and a lot of packages
don't support -R very well.  pkgsrc fixes this up by patching a lot of
Makefiles and pkg-config files, and also passes -L/usr/pkg/lib
-R/usr/pkg/lib to builds.

In pkgsrc, libpq shows up as

  /usr/pkg/lib/libpq.la
  /usr/pkg/lib/libpq.a
  /usr/pkg/lib/libpq.so
  /usr/pkg/lib/libpq.so.4
  /usr/pkg/lib/libpq.so.4.0.1

So I am presuming that you built pgsql with --prefix=/usr/local/pgsql
and are perhaps building postgis with a different prefix.  If you don't
really need different prefixes, use the same one for postfix and pgsql.
If you can use ports or pkgsrc, use that - others have already addressed
your issue, plus the ones you haven't hit yet :-)q

So ideally postgis's build procedure should, when processing the
--with-pgsql directive, add not only -L but also -R on systems that use
-R.  This is not a postgis-specific issue - just adding -L is the
dominant paradigm - so I can't call this a postgis bug.  It's really a
bug in autoconf that doesn't have "figure out if rpath is used" and a
"add lib to link line" constructs.

This was long-winded, but basically

  LDFLAGS="-L/usr/local/pgsql/lib -R/usr/local/pgsql/lib" ./configure

should go a long way towards helping you out.  In general you need to
add CPPFLAGS and LDFLAGS in the environment to configure when you are
using non-default paths.

Or, you can grab pkgsrc and build pgsql and postgis from it, or spiff up
FreeBSD ports to do the same (probably it does 99% already).

random details from my system and config.status/config.log:

gdt 2 ~ > ldd /usr/pkg/bin/pgsql2shp
/usr/pkg/bin/pgsql2shp:
	-lc.12 => /usr/lib/libc.so.12
	-lintl.0 => /usr/lib/libintl.so.0
	-lcrypt.0 => /usr/lib/libcrypt.so.0
	-lcrypto.4 => /usr/lib/libcrypto.so.4
	-lssl.6 => /usr/lib/libssl.so.6
	-lresolv.1 => /usr/lib/libresolv.so.1
	-lpq.4 => /usr/pkg/lib/libpq.so.4

How config.status sets up to re-execute configure:

  exec /bin/sh "./configure" '--enable-rpath' '--datadir=/usr/pkg/share/postgresql/contrib' '--without-libintl-prefix' '--without-libiconv-prefix' '--prefix=/usr/pkg' '--host=i386--netbsdelf' '--mandir=/usr/pkg/man' 'host_alias=i386--netbsdelf' 'CC=cc' 'CFLAGS=-O2 -I/usr/pkg/include -I/usr/include' 'LDFLAGS=-L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib' 'CPPFLAGS=-I/usr/pkg/include -I/usr/include' 'CXX=c++' 'CXXFLAGS=-O2 -I/usr/pkg/include -I/usr/include' $ac_configure_extra_args --no-create --no-recursion


ac_cv_env_LDFLAGS_value='-L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib'

It was created by configure, which was
generated by GNU Autoconf 2.60.  Invocation command line was


  $ ./configure --enable-rpath --datadir=/usr/pkg/share/postgresql/contrib --without-libintl-prefix --without-libiconv-prefix --prefix=/usr/pkg --host=i386--netbsdelf --mandir=/usr/pkg/man


configure:6699: result:  SUMMARY
configure:6701: result:  -------------------------------------------------------
configure:6703: result:  
configure:6705: result:  HOST_OS: netbsdelf
configure:6707: result:  
configure:6709: result:    PGSQL: /n0/gdt/NetBSD-current/pkgsrc/geography/postgresql81-postgis/work/.buildlink/bin/pg_config
configure:6719: result:     GEOS: /usr/pkg/bin/geos-config (with C-API)
configure:6721: result:           (ldflags: -L/usr/pkg/lib -Wl,-R/usr/pkg/lib)
configure:6727: result:     PROJ: prefix=/usr/pkg libdir=/usr/pkg/lib
configure:6731: result:    ICONV: 1 -liconv
configure:6734: result:   
configure:6736: result:  PORTNAME: netbsd
configure:6738: result:    PREFIX: /usr/pkg
configure:6740: result:   EPREFIX: ${prefix}
configure:6742: result:       DOC: ${prefix}/share/doc
configure:6744: result:      DATA: /usr/pkg/share/postgresql/contrib
configure:6746: result:       MAN: /usr/pkg/man
configure:6748: result:       BIN: ${exec_prefix}/bin
configure:6754: result:       EXT: ${exec_prefix}/lib (${exec_prefix}/lib)
configure:6758: result:  -------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 193 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-amd64/attachments/20090317/39395a87/attachment.pgp


More information about the freebsd-amd64 mailing list