Forum OpenACS Q&A: postgres driver won't load, missing crypt; HELP!

For some reason, I simply cannot get the nspostgres.so driver to load. Both PostgreSQL 7 and AOLserver 3 build with no problems on my Linux system (Caldera 2.2). I'm really puzzled as to why the nspostgres.so driver will not load due to an unresolved 'crypt' symbol. I've included relevant excerpts below. I'm using the nspostgres driver included with AOLserver 3. I can't tell from the various pieces of documentation whether I should be using the AOLserver-provided driver, or the 'custom' one from openacs. I've tried putting LIBS+= -l crypt everywhere. Using nm, I can see the crypt symbol in the various libraries, but it still doesn't work. Any ideas?

database parts of nsd.tcl

set servername             "teachit"
set serverdesc             "origen"

set homedir                [file dirname [ns_info config]]
set bindir                 [file dirname [ns_info nsd]]

#set pageroot               ${homedir}/servers/${servername}/pages
set pageroot               /web/teachit/www/
set directoryfile          index.adp,index.html,index.htm

#
# Global server parameters
#
ns_section "ns/parameters"
ns_param   home            $homedir
ns_param   debug           false
ns_param   auxconfigdir    /web/teachit/parameters

#
# Database stuff
#

ns_section "ns/db/drivers"
ns_param     postgres           nspostgres.so

ns_section "ns/db/driver/postgres"
ns_param     datestyle          iso

ns_section "ns/db/pool/main"
ns_param     Driver             postgres
ns_param     Connections        4
ns_param     MaxOpen            1000000000
ns_param     MaxIdle            1000000000
ns_param     DataSource         localhost::teachit
ns_param     User               nsadmin
ns_param     Password           nsadmin
ns_param     Verbose            Off
ns_param     LogSQLErrors       Off
ns_param     ExtendedTableInfo  On

ns_section "ns/db/pool/subquery"
ns_param     Driver             postgres
ns_param     Connections        4
ns_param     MaxOpen            1000000000
ns_param     MaxIdle            1000000000
ns_param     DataSource         localhost::teachit
ns_param     User               nsadmin
ns_param     Password           nsadmin
ns_param     Verbose            Off
ns_param     LogSQLErrors       Off
ns_param     ExtendedTableInfo  On

ns_section "ns/db/pool/log"
ns_param     Driver             postgres
ns_param     Connections        4
ns_param     MaxOpen            1000000000
ns_param     MaxIdle            1000000000
ns_param     DataSource         localhost::teachit
ns_param     User               nsadmin
ns_param     Password           nsadmin
ns_param     Verbose            Off
ns_param     LogSQLErrors       Off
ns_param     ExtendedTableInfo  On

ns_section "ns/db/pools"
ns_param   main                 main
ns_param   subquery             subquery
ns_param   log                  log
excerpt from server.log
[09/Jun/2000:15:41:40][32381.1024][-main-] Notice: loading: 
/usr/local/aolserver/bin/nspostgres.so
[09/Jun/2000:15:41:40][32381.1024][-main-] Warning: could not load 
/usr/local/aolserver/bin/nspostgres.so:  
/usr/local/aolserver/bin/nspostgres.so: undefined symbol: crypt
[09/Jun/2000:15:41:40][32381.1024][-main-] Error: nsd.db: could not 
load driver: postgres
[09/Jun/2000:15:41:40][32381.1024][-main-] Error: nsd.db: no such 
default pool: main
output from ldconfig -p | grep crypt
libcrypt.so.1 (libc6) => /lib/libcrypt.so.1 
procedure for build and install of PostgreSQL 7
./configure --with-tcl --with-odbc
make
make install
procedure for build and install of AOLserver 3
make
make install
cd nspostgres
make
cp nspostgres.so /usr/local/aolserver/bin

Out of desperation, I once again tried compiling the "upgraded" Postgres driver from the OpenACS web site. I added "-lcrypt" to the LDFLAGS variable, did make, and moved it to ~aolserver/bin. After touching up nsd.tcl to reflect the name change of the driver, I restarted AOLserver...and it works. I'm baffled. I did this exact same thing before, without success.

My request to the OpenACS team: make it clear whether or not the "upgraded" driver is still necessary. The wording on the web site and the included documentation makes it tough to figure out.

Oh well. Now on to figuring this whole thing out so I can get a new module written.

It's necessary now and it probably always will be. I looked at the installation documents and under section 5.2 of the install document it says:

5.2 Compiling the PostgreSQL driver for AOLserver 

      Get the enhanced PostgreSQL driver from http://acspg.benadida.com/sdm 
      Edit the Makefile to include the correct path to your PostgreSQL and AOLserver directories. If you are using the RPM version of PostgreSQL, make sure you have the devel package installed as well. 
      Do a make and copy the newly created file postgres.so to the AOLserver's bin directory. 
      If you are running PG 7, make a symbolic link from libpq.so.2.0 pointing to libpq.so.2.1 because AOLserver looks for libpq.so.2.0 when loading the driver. 

cd /usr/local/pgsql/lib
ln -s libpq.so.2.1 libpq.so.2.0    (as postgres)
 

Actually, the nspostgres.so included with AOLserver 3 _final_ should be the same as the one distributed at the openacs site. I have always compiled the postgres driver from the openacs site, but since someone has had problems, I will try using the included nspostgres.so just to make sure it works.

Did you install PostgreSQL in the default location ?

The dependency on libcrypt has absolutely nothing to do with AOLserver, the Postgres driver, or OpenACS.

The dependency was added late in POSTGRES (as opposed to any of the above components) late in the Beta cycle.  It was well-documented in Postgres land, but folks who arrive at Postgres via our narrow little view of life may well have missed it.

In fact, it sorta snuck under our radar.  You can fully expect that future versions of the Makefile involved will include "-lcrypt".

The error comes from the Postgres API library.  We just link it in, and when the dependency was added, our links failed.  That's the long and short.  "-lcrypt" won't hurt if you don't need it...

The dependency on libcrypt has existed since at least 6.5beta under RedHat Linux.

This is becoming a FAQ.

It is easy enough to add -lcrypt to the makefile (which, IIRC, is done for the Redhat lines I added that are commented out, OR you can statically link libpq and libcrypt by adding' /usr/lib/libpq.a' and' /usr/lib/libcrypt.a' to the link line that makes the .so.

Note that statically linking libraries that were not compiled with -fPIC is not recommended due to performance and portability reasons! IE, the statically linked postgres.so from above will possibly be significantly slower on Intel, and likely will not work AT ALL on non-Intel platforms.

To summarize, adding -lcyrpt is required on RedHat Linux in particular, and has been the case since at least 6.5beta -- the build scripts and makefiles were changed at that time to do smoother dynamic libs -- unfortunately, this is one area that a wart still exists. I've had to compile the postgres driver this way for well over a year, with -lcrypt.

--
Lamar Owen
WGCR Internet Radio
1 Peter 4:11

Thanks for all the responses. I realized early that the dependency on libcrypt was there. This dependency exists with a good portion of the software I compile on my system, so it's not even unexpected. For me, there were two points of confusion:

  1. I couldn't figure out, based on the dates on the documentation and the source code for the ACS- and AOL-provided Postgres drivers, which driver I should be using. This is partly contributable to my naivete about the "big picture" concerning ACS (it's getting better by the hour). Partly, it's because the ACS-provided docs sometimes look out of date. (For example, by presenting everything as .ini files, when the latest AOLserver comes with a nsd.tcl file.)
  2. I really did compile and install the ACS-provided driver and got the same results. It was only an attempt to try it again after a private message from Don Baccus that got me success. I still don't know exactly what happened with my first attempt.

Anyway, thanks again for the help. I'm having fun already! :)

We're working on documentation improvements, Roberto Mello's putting the finishing touches on his rewrite of the installation guide and it will use .tcl files throughout.

The source of the .ini and .tcl confusion's pretty simple.  When we began this port, AOLserver3 wasn't exactly ready for prime time, so both ACS Classic (aD's Oracle version) and OpenACS used AOLserver 2.3.3, which only supported initialization via .ini files.

When AOLserver3 got stable, we switched to using it but didn't get OpenACS switched over to using .tcl files immediately, and documentation's been lagging, too.  And aD still hasn't switched all their documentation over to .tcl examples, and we distribute the aD document tree ...