Message-ID: <32665DB2.794B@lig.di.epfl.ch>
Date: Thu, 17 Oct 1996 18:24:18 +0200
From: Pascal Fua <fua@lig.di.epfl.ch>
Organization: Computer Graphics Lab, EPFL
X-Mailer: Mozilla 2.02S (X11; I; IRIX 5.3 IP22)
MIME-Version: 1.0
Newsgroups: comp.lang.lisp.franz
CC: fua, choueiry@lia.di.epfl.ch
Subject: Loading foreign libraries
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 65
NNTP-Posting-Host: disunms.epfl.ch
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!portc01.blue.aol.com!news-e2a.gnn.com!howland.erols.net!math.ohio-state.edu!jussieu.fr!univ-lyon1.fr!in2p3.fr!swidir.switch.ch!epflnews.epfl.ch!ligsg10.epfl.ch

I use allegro 4.3 on SGI's and I have run into the following problem
with the foreign function interface:

This version can only handle shared libraries  and seems to ignore all
the keyword arguments of the "load" function.  As a result I am unable
to  load a library  with some   undefined  symbols, even if those  are
defined by another library  that has already  been loaded (See example
below). 

A way around this problem is to create a single humongous library with
all the object files I need and load everything at once. However, this
is a pain when there are many object files and  it would be nice to be
able to be  able load object files incrementally  in the  same fashion
that lisp files cane be loaded incrementally.

Can it be done?

				         Pascal

---------------------------------------------------------------------
 P. Fua (fua@lig.di.epfl.ch) Tel: 41/21-693-6647  FAX: 41/21-693-5328
                             Url: http://ligwww.epfl.ch/~fua/
---------------------------------------------------------------------


File foo1.c
---------------
double foo1(double x,double y)
{
  return(1+foo2(x,y));
}

File foo2.c
---------------
double foo2(double x,double y)
{
  return(x+y);
}

Under unix
----------
fua@ligsg10[~/acl]% cc -KPIC -c foo2.c
fua@ligsg10[~/acl]% ld -shared -all -o foo2.so foo2.o
fua@ligsg10[~/acl]% cc -KPIC -c foo1.c
fua@ligsg10[~/acl]% ld -shared -all -o foo1.so foo1.o
fua@ligsg10[~/acl]% ld -shared -all -o foo1and2.so foo1.o foo2.o

In lisp
-------

USER(7): (load "foo2.so")
; Foreign loading ./foo2.so.
T
USER(8): (load "foo1.so")
; Foreign loading ./foo1.so.
Error: loading library #p"./foo1.so" caused the following error:
  24701:/logiciels/licences/acl-4.3/bin/pb_clim2xm_composer.img: rld:
Fatal Error: unresolvable symbol in ./foo1.so: foo2

Restart actions (select using :continue):
 0: retry the load of ./foo1.so
 1: skip loading ./foo1.so

The "unresolvable symbol" shold have been defined by "foo2". Of course
(load "foo1and2.so") woorks but has the drawback discussed above.
