[Openmcl-devel] Darwin and shared libraries

alex crain alex at widgetworks.com
Sun Mar 31 20:06:34 PST 2002

I've been digging into the openmcl sources trying to figure out the best 
way to
import external libraries under darwin.

Darwin doesn't allow dynamic linking per-se, in sense that I can't say

   dlopen ("/usr/X11R6/lib/libX11.so", ...)

What I can do is either link that lisp executable with the library at 
load time (-lX11), which works even if there are no symbol references to 
that library, or I can load
a BUNDLE, which is kind of like a shared library but not really. It's 
mostly annoying
because the various system libraries are not bundles, so I'm looking at 
intermediate step no matter what.

Interestingly enough, I can create a bundle with nothing in it that is 
linked to a shared
libary, ie:

% cat > foo.c
void foo () {}
% cc -bundle -flat_namespace -o foo.so foo.c -L/usr/X11R6/lib -lX11

and I get all the symbols from the X11 shared library for free (again 
without an explicit reference)

As a side benefit, library carry references to their dependencies, so I 
can do this:
% cc -bundle -flat_namespace -o foo.so foo.c -L/usr/X11R6/lib -lXt

and I get all the symbols from Xt *and* X11

Which leads to the question of what to do with all this.

My inclination is to create something along the lines of
   (open-module-in-package <package-name> <path>)
which would load a module and import all of it's symbols into the 
package in a single action. We could even go a step further and build 
files that contain a section for a database with the type information. 
This is simple
enough under darwin because bundle files can bundle just about anything, 
I think that elf ought to be able to hande it too, although I'm not sure 
how to
inspire the loader to do it.

This would require building special loadable objects, but the mechanism 
be too complex and the benefit would be getting all the type information 
structure definitions with the load.

I'm not sure how to manage all the library dependencies under LINUX, 
though. Under
darwin it would be free.



Openmcl-devel mailing list
Openmcl-devel at clozure.com

More information about the Openmcl-devel mailing list