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

From: Jon Rafkind (workmin at ccs.neu.edu)
Date: Mon Aug 28 18:58:10 EDT 2006


> 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".
>
>   
I have this code right now working in Linux.

(define *dir*
  (let-syntax ((current-module-directory
         (lambda (stx)
           (datum->syntax-object
             stx (current-load-relative-directory)))))
    (current-module-directory)))

(case (system-type)
  ((unix) (begin
        (ffi-lib "libz")
        (ffi-lib (build-path *dir* "../allegro-4.2.0/lib/unix/libpng12")))))

Im assuming libz is already installed on the machine, I think this is a
safe enough bet. For macosx I tried basically the same thing except the
last ffi-lib was something like (ffi-lib (build-path *dir*
"../allegro-4.2.0/lib/macosx/libpng12")).

The directory structure is like this

allegro.plt/util.ss
allegro.plt/private/allegro.ss ;; this has the code to load the libaries
allegro.plt/allegro-4.2.0/

So loading libpng12 from the allegro sub-directory is fine on unix but
not fine on osx. After more searching I see ___sF is declared in
stdio.h, so it must be part of libc or something.


Posted on the users mailing list.