Subject:
Re: [ruby-ffi] Unable to load .so file - any ideas?
From:
Tony Summerville
Date:
3/7/12 6:53 AM
To:
ruby-ffi@googlegroups.com

Thanks for your answer. That does appear to be the problem as the .so file was compiled for a different flavor of Linux I've come to find out...

Thanks again!

On Tuesday, March 6, 2012 2:39:41 PM UTC-6, cremes wrote:

On Mar 6, 2012, at 9:10 AM, Tony Summerville wrote:

> I'd really appreciate any help or thoughts on this issue.
>
> I'm trying to wrap a simple shared library in a Ruby Gem. The .so file was precompiled by a 3rd-party vendor and I don't have access to the C source files.
>
> I've installed FFI gem v1.0.11 and am able to get the basic "getpid" example working perfectly, but when I try to load the .so file I get the following error:
>
> ruby-1.9.2-p180 :001 > require "prova-vhm-raw2xml"
> LoadError: Could not open library '/Users/tsummerville/.rvm/gems/ruby-1.9.2-p180@prova-vhm-raw2xml/gems/prova-vhm-raw2xml-0.1.0/lib/libZVLParser64/libZVLParser64.so': dlopen(/Users/tsummerville/.rvm/gems/ruby-1.9.2-p180@prova-vhm-raw2xml/gems/prova-vhm-raw2xml-0.1.0/lib/libZVLParser64/libZVLParser64.so, 5): no suitable image found.  Did find:
>         /Users/tsummerville/.rvm/gems/ruby-1.9.2-p180@prova-vhm-raw2xml/gems/prova-vhm-raw2xml-0.1.0/lib/libZVLParser64/libZVLParser64.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
>

> Other potentially relevant notes:
> - I'm on Mac OSX with 64 bit processor
> - The libZVLParser64.so was compiled for 64 bit architecture
>
> Anything obvious that I'm missing? I'm new to FFI and wrapping C libs with Ruby in general, so I'm just not quite sure what I'm doing wrong. I've read through all the documentation and looked through the Google Group but can't figure out what the problem is.
>
> Thanks again for any help or insight you can provide!


What is the output of:

  file /Users/tsummerville/.rvm/gems/ruby-1.9.2-p180@prova-vhm-raw2xml/gems/prova-vhm-raw2xml-0.1.0/lib/libZVLParser64/libZVLParser64.so

It sounds like there is an architecture mismatch, so the output from that should hopefully shed some light on the problem.

cr