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

From: Jon Rafkind (workmin at ccs.neu.edu)
Date: Wed Sep 6 21:47:34 EDT 2006


Eli Barzilay wrote:
> This is probably irrelevant now, but two quick notes:
>
>
> On Aug 29, Matthew Flatt wrote:
>   
>> 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".
>>     
>
> This is good advice in general, but even more so for OSX.  I had a few
> issues with searching for dynamic libraries, and the summary seems to
> be:
> * On Linux there are certain places that are searched, and you can
>   customize them using LD_LIBRARY_PATH for irregular places.
> * On Windows, you either have DLLs in the system directory or the
>   application directory (preferred as a way of avoiding dll hell)
> * On OSX there are things that are "always" installed in some place,
>   and you're supposed to somehow know where they are and use that
>   path.
> This last item sounded very fishy to me, but this is the best I got
> out of asking questions on an OSX newsgroup.  The file search that
> foreign.ss does is not something that you should depend on -- it will
> basically try to pass the argument straight to the underlying system
> (dlopen or the Windows equivalent), then it will try to see if such a
> file exists in "this" directory.  It's still problematic in some
> situations, which is why I'm inclined to make the search simpler
> instead of more featurefull.  (Like passing a version string
> argument...)
>
>
>   
Do you mean ffi libraries should always bundle the native library on
osx( and other os's )? Right now I depend on foreign.ss being able to
find libz because I don't bundle it. On OSX( and *NIX) it always seems
to be in /usr/lib. If libz happened to not be there in osx, but some
crazy place like /Library/Youll/Never/Guess/To/Look/Here/lib would the
better solution be to look in the directory of the planet package?

Also one quick question, why does (system-library-subpath) return
"ppc-macosx/3m" with the mzscheme3m collector? Is 3m really so different?
> On Aug 28, Jon Rafkind wrote:
>   
>> 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)))
>>     
>
> Look for `this-expression-source-directory'.
>
>
>   


Posted on the users mailing list.