From: Henrik Motakef
Subject: Problem installing USQL on CMUCL/FreeBSD
Date: 
Message-ID: <87it0osk6o.fsf@pokey.henrik-motakef.de>
Hi,

I have some trouble getting UncommonSQL to work with CMUCL 18d on
a recent FreeBSD 4.6-STABLE. 

``(mk:oos "UncommonSQL" :compile)'' works fine so far without any
warnings, however, when I try to load the included sample
("usql-tutorial.lisp"), I get the following error message:

| ;;; Loading #p"/opt/lib/lisp/uncommonsql/dbms/postgresql/ffi-cmucl.x86f".
|
|
| Error in function COMMON-LISP::FOREIGN-SYMBOL-ADDRESS-AUX:
|   Unknown foreign symbol: "PQsetdbLogin"

| Restarts:
|   0: [CONTINUE] Return NIL from load of "/opt/lib/lisp/uncommonsql/dbms/postgresql/ffi-cmucl.x86f".
|   1:            Return NIL from load of "cl-library:uncommonsql;dbms;postgresql;system.lisp".
|   2:            Return NIL from load of "doc/usql-tutorial.lisp".
|   3: [ABORT   ] Return to Top-Level.
|
| Debug  (type H for help)
|
| (COMMON-LISP::FOREIGN-SYMBOL-ADDRESS-AUX "PQsetdbLogin")
| Source: Error finding source: 
| Error in function DEBUG::GET-FILE-TOP-LEVEL-FORM:  Source file no longer exists:
|   target:code/x86-vm.lisp.
| 0] 


Out of curiosity, I tried to change the order of the
def-alien-routine's in ffi-cmucl.lisp, and it always fails at the
first one (tried with putting PQfinish before PQsetdbLogin). So I
guess that loading libpq.so.2 fails for some reason.

There is also a file ffi-cmucl.err containing

| Compiling DEFTYPE PSQL-CONN-PTR: 
| Compiling DEFTYPE PSQL-RESULT-PTR: 
| Byte Compiling Top-Level Form: 
| Converted PQSETDBLOGIN.
| Compiling DEF-ALIEN-ROUTINE "PQsetdbLogin": 
| 
| File: /opt/lib/lisp/uncommonsql/dbms/postgresql/ffi-cmucl.lisp
| 
| In: DEF-ALIEN-ROUTINE "PQsetdbLogin"
|   (DEF-ALIEN-ROUTINE "PQsetdbLogin"
|                      PSQL-CONN
|                      (PGHOST C-STRING :IN)
|                      (PGPORT C-STRING :IN)
|                      ...)
| --> BLOCK WITH-ALIEN EXTENSIONS:COMPILER-LET SYMBOL-MACROLET VALUES PROG1 LET 
| --> ALIEN-FUNCALL ALIEN::NATURALIZE 
| ==>
|   (ALIEN::%SAP-ALIEN ALIEN '#<ALIEN::ALIEN-POINTER-TYPE (* T)>)
| Note: Unable to optimize because:
|       Could not optimize away %SAP-ALIEN: forced to do runtime 
| allocation of alien-value structure.

I set *postgresql-so-load-path* to ("/usr/local/lib/libpq.so.2") in
portgresql-loader.lisp, and tried to include "-lcrypt", "-lcrypto" and
"-lssl" in *postgresql-so-libraries*, scince ldd told me that libpq.so
depends on them.

A bit of googling around showed that there were problems with FFI on
FreeBSD some time ago, but as far as I understand that should be
solved by now - especially scince I found a message of someone who has
USQL running on a quite similar system to mine.

So, did I simply overlook something? Or is this setup known not to
work?

(Also, if there is a better place to ask, please point me there. I'm
not sure if this is a cmucl issue, so it might be unwise to ask on
cmucl-help, and I didn't find a mailing list for UncommonSQL in
particular.)

TIA
Henrik