[plt-scheme] Bundling .dylib with a MrEd executable on OS X

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Jan 8 08:18:04 EST 2008

At Tue, 8 Jan 2008 11:03:56 +0100, Erich Rast wrote:
> 1.) Is it possible to put a dynamic library into the MrEd .app bundle  
> on OS X such that the FFI loads this library (even if a corresponding  
> shared library is already installed system- or user-wide on the target  
> system)?
> 2.) If yes to 1, can the FFI be changed globally to load all or  
> specific libraries from the application bundle or do I need to  
> manually hack each Scheme library/module that uses the FFI?

The simplest approach is:

 1. Copy the .dylib into plt/lib, or at least put a soft link
    in plt/lib to the library.

 2. Use

       (define-runtime-path a-lib '(so "a"))
       ... (ffi-lib a-lib) ...

     to access the FFI.

By using `define-runtime-path', you tell the executable distribution
maker to include a copy of the .dylib (and arrange for `a-lib' to point
to the copy).

The .dylib has to be in plt/lib so that the executable maker can find
it. It could also be a user-specific place:

   (build-path (find-system-path 'addon-dir) (version) "lib")


Posted on the users mailing list.