Subject:
Re: [ruby-ffi] [Q] search paths for loading libraries
From:
John Croisant
Date:
5/7/10 7:14 PM
To:
ruby-ffi@googlegroups.com

On Thu, May 6, 2010 at 5:41 PM, Jeremy Voorhis <jvoorhis@gmail.com> wrote:
>
> On Thu, May 6, 2010 at 3:38 PM, Wayne Meissner <wmeissner@gmail.com> wrote:
>>
>> On 7 May 2010 08:31, Jeremy Voorhis <jvoorhis@gmail.com> wrote:
>> > Is it only possible to specify complete, absolute paths to libraries for
>> > ffi_lib? An api similar to Ruby's $: would be convenient for adding
>> > directories to the load path, like FFI.load_paths << '/usr/local/lib'.
>>
>> It would be fairly trivial to add ffi_library_path on a per-module
>> basis.  I'm not sure whether adding it globally is such a good idea -
>> one library can potentially screw another one over that way.
>>
>> If anyone wants to hack on it, look in lib/ffi/library.rb in the
>> ffi_lib method.  Both ruby-ffi and JRuby use the same code for that
>> section, so a patch for one should apply to the other.
>
> +1 to scoping it per-module. I had a feeling that idea was only half-baked
> :)
>

Shameless plug:

My Nice-FFI library <http://github.com/jacius/nice-ffi/> has code to
do exactly what you want. Have a look at the usage guide and see if
you're interested:

  http://github.com/jacius/nice-ffi/blob/master/docs/usage.rdoc

Be aware, the API for Nice-FFI is not considered stable yet, i.e. I
might change stuff in the future (although in practice it doesn't
change much). But all the code is under the MIT License, so you could
package it (or parts of it) with your code if API changes concern you.

- John