Forum OpenACS Q&A: cant get postgres.so driver to work !!!!

Geesh, this postgres.so driver is giving me fits.

It appears to compile fine, but when Aolserver starts up,

I get the following error EVERYTIME !!!!

[29/Aug/2000:22:25:43][972.1024][-main-] Notice:
loading: /home/aolserver/bin/postgres.so

[29/Aug/2000:22:25:43][972.1024][-main-] Warning: could not
load /home/aolserver/bin/postgres.so:  libpq.so.2.1: cannot open
shared object file: No such file or directory

[29/Aug/2000:22:25:43][972.1024][-main-] Error: nsd.db: could not
load driver: postgres

YET, the file DOES EXIST:

lrwxrwxrwx  1 postgres web    12 Aug 29
21:57 /usr/local/pgsql/lib/libpq.so -> libpq.so.2.1

lrwxrwxrwx  1 postgres web            12 Aug 27
11:12 /usr/local/pgsql/lib/libpq.so.2 -> libpq.so.2.1

-rw-r--r--  1 postgres web        57532 Aug 27
11:12 /usr/local/pgsql/lib/libpq.so.2.1

I AM GOING CRAZY WITH THIS PLEASE ADVISE:

mailto:streethockey@ureach.com

Collapse
Posted by Roberto Mello on
As your AOLserver user, can you connect to your database from a shell ? Try "psql yourdb", if you can connect and run queries than it's AOLserver that is not talking to PG.

In the documentation I note that sometimes it's necessarry to link libpq. Did you do that?

Try ldd postgres.so. This will tell you the full pathnames of files that are needed to load postgres.so. Eg. on my system:
[kjk@funky bin]$ ldd postgres.so 
        libpq.so.2.1 => /usr/lib/libpq.so.2.1 (0x4000d000)
        libc.so.6 => /lib/libc.so.6 (0x40020000)
        libcrypt.so.1 => /lib/libcrypt.so.1 (0x40113000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
If you get the same result you would have to copy libpq.so to /usr/lib (or create a symbolic link, or re-link postgres.so so that it gets a better information on where libpq.so.2.1 lives - although I don't know how to do it)
Collapse
Posted by Eric Webber on
Yes I can connect to pgsql as nsadmin, but that is because as postgres, I created a db user named nsadmin.  i.e. postgres works fine.

Where in the docs does it say to link libpq ?  sometimes ?  like when ?  EXACTLY what file name should I link in ? It seems that EVERYONE has had major trouble with this postgres.so driver.  It seems so mysterious, never certain.

Oh, well thanks for the input, here is my make file, what should I add to it in your estimation ?  THANKS AGAIN for responding...

makefile from openacs for pgdriver 1.1  [with my mods]

# Location of the PostgreSQL libraries
PGLIB=/usr/local/pgsql/lib

# Location of the PostgreSQL includes
PGINC=/usr/local/pgsql/include

# Location of the AOLserver files (normally the ~nsadmin directory):
NSHOME=/home/aolserver
NSINC=/var/local/src/aolserver3_0/include

CC=gcc
COPTS=-Wall -fpic -shared -I$(PGINC) -I$(NSINC) -I-/usr/include

# You should not need to edit anything below this line.

EXTRA_OBJS=$(PGLIB)/libpq.so.2.1
OBJS=postgres.o
MODULE=postgres.so
CFLAGS=-DFOR_ACS_USE -I$(NSINC) $(COPTS)
LDFLAGS=-shared -I$(PGINC) -I$(NSINC) -I-/usr/include

all: $(MODULE)

$(MODULE): $(OBJS)
        gcc $(LDFLAGS) -o $(MODULE) $(OBJS) $(EXTRA_OBJS)

install: $(MODULE)
        cp $(MODULE) $(NSHOME)/bin/
        chmod +x $(NSHOME)/bin/$(MODULE)

clean:
        rm -f *.o *.so

Collapse
Posted by Ben Adida on
This is not so mysterious actually, and is exactly the same issue that Oracle people have: your system has to know where to find the shared libraries of the Postgres driver. I recommend *against* making copies or symlinks in your /usr/lib directory, which will crowd things in there.

Instead, you should set things up so that the library load path will find the libpq stuff. If you're under Linux, the recommended way of doing this is to edit your /etc/ld.so.conf file and add /usr/local/pgsql/lib to it, then to run /sbin/ldconfig (all as root). Otherwise, you will need to wrap your nsd in a shell script that sets the LD_LIBRARY_PATH correctly.

Collapse
Posted by matt wilkie on
I had to to create a sym link from libpq.so to libpq.so.2.0 which in turn is sym linked to 2.1:
# ls -l /usr/lib/libpq.so*
lrwxrwxrwx 1 root root 12 Aug 30 03:37 /usr/lib/libpq.so -> libpq.so.2.0
lrwxrwxrwx 1 root root 12 Jul 20 03:52 usr/lib/libpq.so.2 -> libpq.so.2.1
lrwxrwxrwx 1 root root 21 Aug 30 03:47 usr/lib/libpq.so.2.0 -> /usr/lib/libpq.so.2.1
-rw-r--r-- 1 root root 66296 Jun 16 03:26 usr/lib/libpq.so.2.1
Collapse
Posted by Jade Rubick on
I'm having much the same problem as Eric. I have a question:
  • My postgres driver is from the Aolserver distribution. Is this legitimate? If so, should I rename it from nspostgres.so to postgres.so?
Collapse
Posted by Jade Rubick on
I eventually just downloaded the Postgres driver again and got it working this time. You have to be careful where you set the paths to in the makefile, or it won't compile.
Collapse
Posted by mike van steen on
I too experienced this problem and tried a few things.

Ben's solution
" ... /etc/ld.so.conf file and add /usr/local/pgsql/lib to it, then to run /sbin/ldconfig (all as root). ..." (etc)  worked within 15 seconds.

Background -- slackware distro, running postgres 7, aol 3.2