Subject: Re: [ruby-ffi] invalid ELF header on hello world example |
From: Wayne Meissner |
Date: 5/26/10 6:25 PM |
To: ruby-ffi@googlegroups.com |
Don't use 'libc' as the library, use FFI::Library::LIBC On linux, /usr/lib/libc.so is a linker script, not a library. (you have to use libc.so.6, which is what FFI::Library::LIBC will be on linux) If thats in an example on the wiki, please correct it, or if its in the source tree, report and issue with a patch for it. On 27 May 2010 09:09, bwv549 <jtprince@gmail.com> wrote:
/home/jtprince/.gem/ruby/1.9.1/gems/ffi-0.6.3/lib/ffi/library.rb:61:in `block in ffi_lib': Could not open library 'libc': libc: cannot open shared object file: No such file or directory. Could not open library 'libc.so': /usr/lib/libc.so: invalid ELF header (LoadError) from /home/jtprince/.gem/ruby/1.9.1/gems/ffi-0.6.3/lib/ffi/library.rb: 43:in `map' from /home/jtprince/.gem/ruby/1.9.1/gems/ffi-0.6.3/lib/ffi/library.rb: 43:in `ffi_lib' from hello.rb:7:in `<module:Hello>' from hello.rb:5:in `<main>' Seems like it can see libc but says "invalid ELF header". How do I get hello world to run on linux?--- require 'ffi' LIBC = 'libc' module Hello extend FFI::Library ffi_lib LIBC attach_function 'puts', [ :string ], :int end Hello.puts("Hello, World") --- Gives me: