Subject:
Re: [ruby-ffi] Proper way to refer to libcrack.so.2
From:
Wayne Meissner
Date:
5/11/12 8:37 PM
To:
ruby-ffi@googlegroups.com


Although I think those are both useful suggestions, like all the other feature suggestions I've been getting, I've been pushing back and recommending they be done in a third-party gem.  That way, the new features can be used on e.g. JRuby without the lag of waiting until JRuby's FFI implements the new feature (installing the ffi gem on jruby does not update the ffi implementation, since it is internal to JRuby).

ffi_lib is implemented in ruby, so implementing an alternative version of it won't be that hard, should work across all implementations, and making use of it in a gem can be as easy as:

require 'ffi-xtra'

module FooLib
  extend FFI::Xtra::Library

  ffi_lib 'crack', '>= 2' # loads "libcrack.so.2"

  ... # attach_function, etc
end

I'm happy for source for such a gem to be hosted under the ffi github org, and make it the 'official' extra-features-that-people-want gem we can throw all this type of stuff into it.



On Friday, 11 May 2012 18:55:59 UTC+10, Matijs van Zuijlen wrote:
Something like that would be great. A helper method to list available versions
would also be nice; I'm now relying on a rather unpleasant set of rescue blocks
to load either the preferred version or an unsupported version of a library
(with proper warnings shown, of course).

On 05/11/2012 08:59 AM, postmodern wrote:
> This brings up a feature I wanted to request. Most Linux distributions
> have moved the primary "libfoo.so" file into "foo-dev" or "foo-devel"
> packages, with the "libfoo" package containing "libfoo.so.X". Maybe in
> the future, you could specify the Major version of the library you wish
> to load?
>
>      ffi_lib 'crack', '>= 2' # loads "libcrack.so.2"
>
> On 05/10/2012 11:40 PM, broberts wrote:
>> On CentOS cracklib is deploy as libcrack.so.2 which is a symlink to
>> libcrack.so.2.8.1. There is no libcrack.so. Referring to this library
>> using:
>>
>> ffi_lib 'crack'
>>
>> fails with a file not found error. Referring to the library using:
>>
>> ffi_lib 'crack.so.2'
>>
>> succeeds. I assume that this is the expected behavior but I wanted to
>> make sure before I get too far down the road.
>>
>> Thanks for any help.
>>
>> Baron

--
Matijs