Subject:
Re: [ruby-ffi] Re: Multiple libraries included via dlopen()?
From:
Michael MacDonald
Date:
12/17/10 10:44 AM
To:
ruby-ffi@googlegroups.com

On Thu, Dec 16, 2010 at 10:46 PM, Wayne Meissner <wmeissner@gmail.com> wrote:
You probably don't need to backport all the machinery in ffi_lib_flags
and ffi_lib, you can might get away with using something like:

GlobalSlurm = DynamicLibrary.open(FFI.map_library_name('slurm'),
FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_GLOBAL)

That should re-open the library as global.  (storing it in a constant
just keeps the library handle alive, and hence from being closed when
GC is performed).

Wow!  Yet again, thanks for the expert advice.  Just confirmed that this approach seems to work fine with an unmodified 0.6.3.

Do you see any downside to using this approach regardless of the FFI gem version?  Aside from uglyness, that is.  I could probably implement something which uses ffi_lib_flags for 1.0.0+, but I'm not sure if there's any benefit other than aesthetics.

Mike