Subject:
Re: [ruby-ffi] A really simple example: Segmentation fault
From:
Wayne Meissner
Date:
1/31/10 6:33 PM
To:
ruby-ffi@googlegroups.com

On 1 February 2010 05:39, Jesús GS <blaxter@gmail.com> wrote:
> $ more example.rb
> require 'rubygems'
> require 'ffi'

> extend FFI::Library
> ffi_lib './libsample.so'
> attach_function :foo, :foo, [:int], :int


You need to enclose the above in a module.
e.g.
module LibSample
  extend FFI::Library
  fi_lib './libsample.so'
  attach_function :foo, :foo, [:int], :int
end

And call it as
LibSample.foo(1)