# Ffi library refuses to load

**URL:** <https://rubytalk.org/t/ffi-library-refuses-to-load/61037>\
**Category:** ruby-talk\
**Created:** [3 December 2010 05:11 UTC](https://rubytalk.org/t/ffi-library-refuses-to-load/61037 "2010-12-03T05:11:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luther1](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@Luther1](https://rubytalk.org/u/Luther1)\
**Post date:** [3 December 2010 05:11 UTC](https://rubytalk.org/t/ffi-library-refuses-to-load/61037/1 "2010-12-03T05:11:50Z")

</div>

I'm trying to run a sample program from rubygame, but it claims a  
library file from ffi is missing. From my terminal:

luther@hrimfaxi:/usr/local/lib/ruby/gems/1.9.1/gems$  
./rubygame-2.6.4/samples/demo\_rubygame.rb  
\<internal:lib/rubygems/custom\_require\>:29:in `require': libffi.so.4:  
cannot open shared object file: No such file or directory -  
/usr/local/lib/ruby/gems/1.9.1/gems/ffi-1.0.0/lib/ffi\_c.so (LoadError)  
&nbsp;&nbsp;from \<internal:lib/rubygems/custom\_require\>:29:in `require'  
&nbsp;&nbsp;from /usr/local/lib/ruby/gems/1.9.1/gems/ffi-1.0.0/lib/ffi.rb:8:in  
`rescue in \<top (required)\>'  
&nbsp;&nbsp;from /usr/local/lib/ruby/gems/1.9.1/gems/ffi-1.0.0/lib/ffi.rb:1:in  
`\<top (required)\>'  
&nbsp;&nbsp;from \<internal:lib/rubygems/custom\_require\>:29:in `require'  
&nbsp;&nbsp;from \<internal:lib/rubygems/custom\_require\>:29:in `require'  
&nbsp;&nbsp;from  
/usr/local/lib/ruby/gems/1.9.1/gems/nice-ffi-0.4/lib/nice-ffi.rb:31:in  
`\<top (required)\>'  
&nbsp;&nbsp;from \<internal:lib/rubygems/custom\_require\>:29:in `require'  
&nbsp;&nbsp;from \<internal:lib/rubygems/custom\_require\>:29:in `require'  
&nbsp;&nbsp;from  
/usr/local/lib/ruby/gems/1.9.1/gems/ruby-sdl-ffi-0.3/lib/ruby-sdl-ffi/sdl.rb:31:in  
`\<top (required)\>'  
&nbsp;&nbsp;from \<internal:lib/rubygems/custom\_require\>:29:in `require'  
&nbsp;&nbsp;from \<internal:lib/rubygems/custom\_require\>:29:in `require'  
&nbsp;&nbsp;from  
/usr/local/lib/ruby/gems/1.9.1/gems/rubygame-2.6.4/lib/rubygame/main.rb:22:in  
`\<top (required)\>'  
&nbsp;&nbsp;from \<internal:lib/rubygems/custom\_require\>:29:in `require'  
&nbsp;&nbsp;from \<internal:lib/rubygems/custom\_require\>:29:in `require'  
&nbsp;&nbsp;from  
/usr/local/lib/ruby/gems/1.9.1/gems/rubygame-2.6.4/lib/rubygame.rb:44:in  
`block in \<top (required)\>'  
&nbsp;&nbsp;from  
/usr/local/lib/ruby/gems/1.9.1/gems/rubygame-2.6.4/lib/rubygame.rb:29:in  
`each'  
&nbsp;&nbsp;from  
/usr/local/lib/ruby/gems/1.9.1/gems/rubygame-2.6.4/lib/rubygame.rb:29:in  
`\<top (required)\>'  
&nbsp;&nbsp;from \<internal:lib/rubygems/custom\_require\>:33:in `require'  
&nbsp;&nbsp;from \<internal:lib/rubygems/custom\_require\>:33:in `rescue in require'  
&nbsp;&nbsp;from \<internal:lib/rubygems/custom\_require\>:29:in `require'  
&nbsp;&nbsp;from ./rubygame-2.6.4/samples/demo\_rubygame.rb:25:in `\<main\>'  
luther@hrimfaxi:/usr/local/lib/ruby/gems/1.9.1/gems$ ll  
ffi-1.0.0/lib/ffi\_c.so  
-rwxr-xr-x 1 root root 525k 2010-12-02 Thu 20:39:04  
ffi-1.0.0/lib/ffi\_c.so

As you can see from the ll command at the bottom, the file is most  
definitely there. This is very frustrating. Any ideas?

I'm using 'ruby 1.9.2p0 (2010-08-18 revision 29036) [x86\_64-linux]',  
compiled from source, on Trisquel 4.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Ryan\_Davis1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/ryan_davis1/32/1848_2.png) [@Ryan\_Davis1](https://rubytalk.org/u/Ryan_Davis1)\
**Post date:** [3 December 2010 08:39 UTC](https://rubytalk.org/t/ffi-library-refuses-to-load/61037/2 "2010-12-03T08:39:27Z")

</div>

Just a guess, I think this is saying libffi.so.4 is missing, not ffi\_c.so.

> **···**
>
> On Dec 2, 2010, at 21:11 , Luther Thompson wrote:
> 
> > \<internal:lib/rubygems/custom\_require\>:29:in `require': libffi.so.4:  
> > cannot open shared object file: No such file or directory -  
> > /usr/local/lib/ruby/gems/1.9.1/gems/ffi-1.0.0/lib/ffi\_c.so (LoadError)

---

<div class="post-metadata">

**Author:** ![Luther1](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@Luther1](https://rubytalk.org/u/Luther1)\
**Post date:** [3 December 2010 15:25 UTC](https://rubytalk.org/t/ffi-library-refuses-to-load/61037/3 "2010-12-03T15:25:14Z")

</div>

Is there any way to confirm that? And if it's true, how can I fix it?  
And why doesn't 'gem install' catch the error?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Ammar\_Ali](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Ammar\_Ali](https://rubytalk.org/u/Ammar_Ali)\
**Post date:** [3 December 2010 16:16 UTC](https://rubytalk.org/t/ffi-library-refuses-to-load/61037/4 "2010-12-03T16:16:18Z")

</div>

> Is there any way to confirm that? And if it's true, how can I fix it?

Try:  
$ locate libffi

If it's not found, then either use your system's package manager to  
install it, or grab the source from [libffi](http://sourceware.org/libffi/) and  
compile/install it yourself.

> And why doesn't 'gem install' catch the error?

The gem checks for the library (via pkg-config) and for the required  
development header. I'm not familiar with Trisquel, perhaps it uses  
different conventions that are not covered/tested by the gem.

HTH,  
Ammar

> **···**
>
> On Fri, Dec 3, 2010 at 5:25 PM, Luther Thompson \<lutheroto@gmail.com\> wrote:

---

<div class="post-metadata">

**Author:** ![Luther1](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@Luther1](https://rubytalk.org/u/Luther1)\
**Post date:** [3 December 2010 18:57 UTC](https://rubytalk.org/t/ffi-library-refuses-to-load/61037/5 "2010-12-03T18:57:21Z")

</div>

It works now. Thanks a lot for the help. Details below.

Ammar Ali wrote in post #965991:

> Try:  
> $ locate libffi

That showed me two files which, in my uninformed opinion, should have  
been valid:  
/usr/lib/libffi.so.5  
/usr/local/lib64/libffi.so.4

> If it's not found, then either use your system's package manager to  
> install it, or grab the source from [libffi](http://sourceware.org/libffi/) and  
> compile/install it yourself.

In Synaptic, I installed libffi-dev. Then I did 'sudo gem pristine ffi'.  
Running demo\_rubygame.rb still gave me the same error.

Then, I installed libffi from source. Still the same error.

Then, I remembered to do 'sudo gem pristine ffi', and now it \*does\*  
work!

> > And why doesn't 'gem install' catch the error?
> 
> The gem checks for the library (via pkg-config) and for the required  
> development header. I'm not familiar with Trisquel, perhaps it uses  
> different conventions that are not covered/tested by the gem.

Trisquel is based on Ubuntu. I do have a pkg-config command.

Thanks again...  
Luther

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Ammar\_Ali](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Ammar\_Ali](https://rubytalk.org/u/Ammar_Ali)\
**Post date:** [4 December 2010 05:32 UTC](https://rubytalk.org/t/ffi-library-refuses-to-load/61037/6 "2010-12-04T05:32:22Z")

</div>

You're welcome. Trisquel sounds interesting, I'd never heard of it before.

Regards,  
Ammar

> **···**
>
> On Fri, Dec 3, 2010 at 8:57 PM, Luther Thompson \<lutheroto@gmail.com\> wrote:
> 
> > Then, I remembered to do 'sudo gem pristine ffi', and now it \*does\*  
> > work!
> > 
> > > > And why doesn't 'gem install' catch the error?
> > > 
> > > The gem checks for the library (via pkg-config) and for the required  
> > > development header. I'm not familiar with Trisquel, perhaps it uses  
> > > different conventions that are not covered/tested by the gem.
> > 
> > Trisquel is based on Ubuntu. I do have a pkg-config command.
> > 
> > Thanks again...
