Subject: Re: [ruby-ffi] Behavior of ffi_lib with Arrays (Was: lists only one lib?) |
From: Wayne Meissner |
Date: 1/24/10 6:28 PM |
To: ruby-ffi@googlegroups.com |
2009/12/22 John Croisant <jacius@gmail.com>:
<wmeissner@gmail.com> wrote:On Sat, Dec 19, 2009 at 6:35 AM, Wayne MeissnerYou need to list them all on the same line. i.e. ffi_lib 'user32', 'msvcrt'I always thought that giving multiple args to ffi_lib was a way of providing fallback libraries /alternate names in case the first one failed. I guess I assumed that it didn't make sense (or wouldn't work) to load more than one library into the same module, anyway. I'm not sure why I assumed that, though.
the way ffi_lib handles multiple args changed in 0.6:
now, ffi_lib "a", "b", "c" will fail if _any_ of a, b, or c fail to load.
If you need alternate library names (e.g. for linux shared libs), you can use []
e.g.
# try to load libncurses, fall back to libncurses.so.5 on linux if
that fails, but also load libc
ffi_lib [ "ncurses", "libncurses.so.5" ], FFI::Platform::LIBC
However, a better idea is probably to use NiceFFI and its find_library function.