Subject:
Re: [ruby-ffi] Re: puts example fails in doze
From:
Wayne Meissner
Date:
12/18/09 3:41 PM
To:
ruby-ffi@googlegroups.com

2009/12/19 Luis Lavena <luislavena@gmail.com>:
>> works in linux without doing an explicit ffi_lib call...I'm curious as
>> to why windows require ffi_lib 'msvcrt', when it is linked against
>> msvcrt in the beginning to start with (I guess)?
>> Any ideas there?
>
> Mentioned in another thread about default library being used
> automatically. I guess the gem didn't had the support baked in?

That has changed in ruby-ffi 0.6.0 & JRuby 1.5.0; you now need to
explicitly specify the library, or specify
FFI::Library::CURRENT_PROCESS as the library.

Tips (as of 0.6.0):

1) FFI::Library::LIBC will always be the correct
libc.so/libc.dylib/msvcrt.dll for the current platform.

2) Avoid using FFI::Library::CURRENT_PROCESS, unless you're hacking
ruby VM internals using FFI.  The set of libraries that are loaded
into the VM differ from VM to VM and from OS to OS, so relying on the
current process having e.g. calloc(3) in its symbol table will lead to
your program/library breaking.