Forum OpenACS Q&A: Problems compiling nspostgres on Debian stable while using the Aolserver 4 docs

I've followed the installation guide (both the HEAD and 5.0 versions are the same on these points), and everything proceeds smoothly until I get to the part where I'm installing nspostgres.

As the docs mention, when I compile nspostgres, I get the following output:

dev2:/usr/local/src/aolserver40r2/nspostgres# make install POSTGRES=/usr/local/pgsql/ ACS=1 INST=/usr/local/aolserver40r2
gcc -pipe -DBIND_EMULATION -I/usr/local/pgsql/include -DFOR_ACS_USE -O -D__NO_STRING_INLINES -D__NO_MATH_INLINES -Wall -Wconversion -Wno-implicit-int -fPIC  -I/usr/local/aolserver40r2/include -I/usr/local/include -DNO_CONST  -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 -DTCL_THREADS=1 -DUSE_THREAD_ALLOC=1 -D_REENTRANT=1 -D_THREAD_SAFE=1 -DHAVE_PTHREAD_ATTR_SETSTACKSIZE=1 -DHAVE_READDIR_R=1 -D_LARGEFILE64_SOURCE=1 -DTCL_WIDE_INT_TYPE=long\ long -DHAVE_STRUCT_STAT64=1 -DHAVE_TYPE_OFF64_T=1 -DHAVE_GETCWD=1 -DHAVE_OPENDIR=1 -DHAVE_STRSTR=1 -DHAVE_STRTOL=1 -DHAVE_STRTOLL=1 -DHAVE_STRTOULL=1 -DHAVE_TMPNAM=1 -DHAVE_WAITPID=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_PARAM_H=1 -DUSE_TERMIOS=1 -DHAVE_SYS_TIME_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_TM_ZONE=1 -DHAVE_GMTIME_R=1 -DHAVE_LOCALTIME_R=1 -DHAVE_TM_GMTOFF=1 -DHAVE_TIMEZONE_VAR=1 -DHAVE_ST_BLKSIZE=1 -DSTDC_HEADERS=1 -DHAVE_SIGNED_CHAR=1 -DHAVE_LANGINFO=1 -DPEEK_XCLOSEIM=1 -DHAVE_SYS_IOCTL_H=1  -DHAVE_TIMEGM=1 -DHAVE_POLL=1 -DHAVE_DRAND48=1 -DHAVE_RANDOM=1 -DHAVE_CMMSG=1    -c -o nspostgres.o nspostgres.c
nspostgres.c: In function `Ns_PgTableList':
nspostgres.c:679: warning: passing arg 3 of `Tcl_DStringAppend' as signed due to prototype
nspostgres.c: In function `encode3':
nspostgres.c:749: warning: passing arg 1 of `enc_one' with different width due to prototype
nspostgres.c:750: warning: passing arg 1 of `enc_one' with different width due to prototype
nspostgres.c:751: warning: passing arg 1 of `enc_one' with different width due to prototype
nspostgres.c:752: warning: passing arg 1 of `enc_one' with different width due to prototype
nspostgres.c: In function `decode3':
nspostgres.c:772: warning: passing arg 1 of `get_one' with different width due to prototype
nspostgres.c:773: warning: passing arg 1 of `get_one' with different width due to prototype
nspostgres.c:774: warning: passing arg 1 of `get_one' with different width due to prototype
nspostgres.c:775: warning: passing arg 1 of `get_one' with different width due to prototype
nspostgres.c: In function `stream_actually_write':
nspostgres.c:864: warning: passing arg 3 of `write' as unsigned due to prototype
nspostgres.c: In function `blob_send_to_stream':
nspostgres.c:980: warning: `fd' might be used uninitialized in this function
nspostgres.c:982: warning: `conn' might be used uninitialized in this function
nspostgres.c: In function `parse_bind_variables':
nspostgres.c:1211: warning: unused variable `first_bind'
nspostgres.c: In function `PgBindCmd':
nspostgres.c:1327: warning: unused variable `value_frag_len'
/bin/rm -f nspostgres.so
gcc -pipe -shared -nostartfiles -L/usr/local/aolserver40r2/lib -o nspostgres.so nspostgres.o -L/usr/local/pgsql/lib -lpq -lnsdb -lnsdb -lnsthread -lnsd -L/usr/local/lib -ltcl8.4 -ldl  -lpthread -lieee -lm -Wl,-rpath,/usr/local/aolserver40r2/lib -Wl,-rpath,/usr/local/lib
/usr/local/aolserver40r2/bin/install-sh -c nspostgres.so /usr/local/aolserver40r2/bin/

However, then I do:

dev2:/usr/local/src/aolserver40r2/nspostgres# ldd nspostgres.so
        libpq.so.3 => not found
        libnsdb.so => /usr/local/aolserver40r2/lib/libnsdb.so (0x40010000)
        libnsthread.so => /usr/local/aolserver40r2/lib/libnsthread.so (0x40018000)
        libnsd.so => /usr/local/aolserver40r2/lib/libnsd.so (0x4001f000)
        libtcl8.4.so => /usr/local/lib/libtcl8.4.so (0x4006d000)
        libdl.so.2 => /lib/libdl.so.2 (0x4010e000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x40111000)
        libm.so.6 => /lib/libm.so.6 (0x40125000)
        libc.so.6 => /lib/libc.so.6 (0x40146000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)

Am I safe to proceed? Any suggestions?

I've tried a number of things:

1) Tried editing the makefile to add in the -lnsdb flag

2) Tried exporting LD_LIBRARY_PATH with aolserver/lib, with /usr/local/pgsql/lib and /usr/local/pgsql/include

3) Checked permissions on the /usr/local/pgsql/include files. They seem okay.

I'm really at a loss as to where to proceed next.

Responding to Dave's question on CVS:

I'm using Postgres 7.3.4 and 7.3.6 (on two different Debian stable machines), and the nspostgres from the Aolserver 4.02 in cvs.

I'm still stuck!

Are you using debian's postgresql package or did you install pg from source? If it's the former did you try to put this in the Makefile:

PGLIB = /usr/lib/postgresql
PGINC = /usr/include/postgresql

instead of the ifeq block in there?

I installed from source.

I'm not exactly sure why, but if I put /usr/local/pgsql in the LD_LIBRARY_PATH environmental variable, it would compile (with lots of warnings), and link in correctly. I put a note in the installation docs on HEAD to this affect. It seems to be working for me so far...