From: Sean O'Halpin Date: 2008-11-04T23:46:24+09:00 Subject: Re: [ANN] FFI 0.1.1 (Foreign Function Interface) for Ruby 1.8.6/7 and 1.9 On Tue, Nov 4, 2008 at 2:38 PM, Ken Bloom wrote: > > Based on all of the examples I've seen, there's something that's still > not clear to me. How does ruby-ffi know which library to load to find the > specified function? > > --Ken > Use ffi_lib in the extended module, e.g. require 'rubygems' require 'ffi' module NCursesFFI extend FFI::Library ffi_lib 'ncurses' attach_function 'clear', [], :int attach_function 'endwin', [], :int attach_function 'getch', [], :int attach_function 'initscr', [], :int attach_function 'printw', [ :string ], :int attach_function 'refresh', [], :int end NCursesFFI.initscr NCursesFFI.printw("Hello again") NCursesFFI.refresh NCursesFFI.getch NCursesFFI.endwin Regards, Sean