Subject:
[ruby-ffi] Could not open library 'C' on Mac OS X Lion 10.7.2
From:
来诺 <winfield301@gmail.com>
Date:
11/28/11 2:08 AM
To:
ruby-ffi@googlegroups.com

Hi, guys

  I have the following code copied from the ruby-ffi github page. I have Xcode installed. tested both in ruby ruby-1.8.7-p352 [ i686 ] and ruby-1.9.2-p180 [ x86_64 ]
  but got the error: 

  gems/ffi-1.0.11/lib/ffi/library.rb:121:in `block in ffi_lib': Could not open library 'c': dlopen(c, 5): image not found. (LoadError)
Could not open library 'libc.dylib': dlopen(libc.dylib, 5): image not found

  the code:

  require 'rubygems'
  require 'ffi'

  module MyLib
    extend FFI::Library
    ffi_lib 'c'
    attach_function :puts, [ :string ], :int
  end

  MyLib.puts 'Hello boys using libc!'