[plt-scheme] loading libraries into memory with ffi-lib on osx

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Aug 28 18:40:38 EDT 2006

At Sun, 27 Aug 2006 20:12:30 -0400, Jon Rafkind wrote:
> The Allegro library that I have been working with depends on libz and
> libpng to function so normally I load those libraries into main memory
> so that all the symbols can be found. Something like
> (ffi-lib "libz")
> (ffi-lib "libpng")
> (define liballegro (ffi-lib "liballeg"))
> This works fine in linux and windows but on OSX it doesnt seem to work.
> I have to put libz and libpng in /usr/lib or /usr/local/lib otherwise I
> get undefined symbol errors when loading liballeg. Does the ffi-lib
> mechanism work differently in OS X? 

I don't think it's so different from Linux. Can you clarify how libz
and libpng are found under Linux?

In general, I think it's probably best to specify paths with `ffi-lib'.
For example, you might include the libraries in a "compiled/native"
sub-directory of the collection, and then use `build-path' and
`this-expression-source-directory'. If might also be a good idea to use
a sub-directory of the "native" directory that is named by
`(system-library-subpath)', instead of putting the libraries directly
in "native".


Posted on the users mailing list.