blakejakopovic / piface

Ruby gem for using PiFace Extension Board (and Raspberry Pi)
MIT License
10 stars 6 forks source link

Could not open library libpiface-1.0 #1

Closed elvisimprsntr closed 11 years ago

elvisimprsntr commented 11 years ago

I am trying to get piface C libraries, FFI, and your Ruby gem working together with SiriProxy. Here are the instructions I have assembled between the C libraries and your gem. https://github.com/elvisimprsntr/siriproxy-piface#installation-new-for-siriproxy-050

piface C libraries, FFI and piface gem all seemed to install without any errors.
Unfortunately, I get the following Ruby error messages: What am I missing?

/usr/local/rvm/gems/ruby-2.0.0-p0/gems/ffi-1.5.0/lib/ffi/library.rb:123:in block in ffi_lib': Could not open library 'libpiface-1.0': libpiface-1.0: cannot open shared object file: No such file or directory. (LoadError) Could not open library 'libpiface-1.0.so': libpiface-1.0.so: cannot open shared object file: No such file or directory from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/ffi-1.5.0/lib/ffi/library.rb:90:inmap' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/ffi-1.5.0/lib/ffi/library.rb:90:in ffi_lib' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/PiFace-0.1.0/lib/piface/native.rb:6:inmodule:Native' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/PiFace-0.1.0/lib/piface/native.rb:4:in <module:PiFace>' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/PiFace-0.1.0/lib/piface/native.rb:3:in<top (required)>' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/PiFace-0.1.0/lib/piface.rb:2:in require' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/PiFace-0.1.0/lib/piface.rb:2:in<top (required)>' from /root/plugins/siriproxy-piface/lib/siriproxy-piface.rb:1:in require' from /root/plugins/siriproxy-piface/lib/siriproxy-piface.rb:1:in<top (required)>'

blakejakopovic commented 11 years ago

I would first check that the C libpiface-1.0 library is installed and working by running their example C code https://github.com/thomasmacpherson/piface#c

I'm setting siriproxy up locally now, so I will let you know how it goes.

blakejakopovic commented 11 years ago

I've installed siriproxy from scratch without errors. Note that I used rbenv instead of rvm.

I expect the problem to be with either

FFI will look for the existence of /usr/local/lib/libpiface-1.0.so, so you can check to see if the file exists.

$ ls /usr/local/lib/
(you should see libpiface-1.0.so)
elvisimprsntr commented 11 years ago

The files exist in the directory you mention FFI will look for them.

root@raspberrypi:/usr/local/lib# ls -lart total 56 drwxrwsr-x 4 root staff 4096 Feb 9 01:38 python2.7 drwxrwsr-x 3 root staff 4096 Feb 9 02:11 python3.2 drwxrwsr-x 11 root staff 4096 Mar 22 20:04 .. drwxr-sr-x 3 root staff 4096 Mar 24 01:57 perl -rwxr-xr-x 1 root staff 13350 Apr 3 00:31 libpiface-1.0.so.0.0.0 lrwxrwxrwx 1 root staff 22 Apr 3 00:31 libpiface-1.0.so.0 -> libpiface-1.0.so.0.0.0 lrwxrwxrwx 1 root staff 22 Apr 3 00:31 libpiface-1.0.so -> libpiface-1.0.so.0.0.0 -rwxr-xr-x 1 root staff 976 Apr 3 00:31 libpiface-1.0.la -rw-r--r-- 1 root staff 11128 Apr 3 00:31 libpiface-1.0.a drwxrwsr-x 6 root staff 4096 Apr 3 00:31 . drwxr-sr-x 2 root staff 4096 Apr 3 00:31 pkgconfig root@raspberrypi:/usr/local/lib#

I installed RVM, Ruby and SiriProxy as root. This was intentional since this eliminates a lot of errors when installing as a user.

Elvis

On Apr 2, 2013, at 10:32 PM, Blake Jakopovic notifications@github.com wrote:

I've installed siriproxy from scratch without errors. Note that I used rbenv instead of rvm.

I expect the problem to be with either

libpiface-1.0 installation (most likely) or user permissions FFI will look for the existence of /usr/local/lib/libpiface-1.0.so, so you can check to see if the file exists.

$ ls /usr/local/lib/ (you should see libpiface-1.0.so) — Reply to this email directly or view it on GitHub.

elvisimprsntr commented 11 years ago

Also saw this file.

root@raspberrypi:/usr/local/lib/pkgconfig# cat piface-1.0.pc prefix=/usr/local exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include

Name: PiFace Description: C interface for the PiFace Raspberry Pi add on. Requires: Version: 0.1 Libs: -L${libdir} -lpiface-1.0 Cflags: -I${includedir}/piface-1.0 -I${libdir}/piface-1.0/include root@raspberrypi:/usr/local/lib/pkgconfig#

Elvis

On Apr 2, 2013, at 10:32 PM, Blake Jakopovic notifications@github.com wrote:

I've installed siriproxy from scratch without errors. Note that I used rbenv instead of rvm.

I expect the problem to be with either

libpiface-1.0 installation (most likely) or user permissions FFI will look for the existence of /usr/local/lib/libpiface-1.0.so, so you can check to see if the file exists.

$ ls /usr/local/lib/ (you should see libpiface-1.0.so) — Reply to this email directly or view it on GitHub.

blakejakopovic commented 11 years ago

Are you able to run the example pfio.c code? https://github.com/thomasmacpherson/piface#c

$ cat piface_program.c
#include <libpiface-1.0/pfio.h>

int main(void)
{
   pfio_init();
   pfio_digital_write(1, 1);
   pfio_deinit();
}
$ gcc -L/usr/local/lib/ -lpiface-1.0 -o piface_program piface_program.c
$ ./piface_program
blakejakopovic commented 11 years ago

I've read that creating a symlink can fix the problem (although it is not a permanent solution). You can try

$ sudo ln -s /usr/local/lib/libpiface-1.0.so. libpiface-1.0.so

Also, what do you get for

$ uname -a
elvisimprsntr commented 11 years ago

root@raspberrypi:/usr/local/lib# uname -a Linux raspberrypi 3.6.11+ #371 PREEMPT Thu Feb 7 16:31:35 GMT 2013 armv6l GNU/Linux root@raspberrypi:/usr/local/lib#

A symbolic link already exists

root@raspberrypi:/usr/local/lib# ls -lart total 56 drwxrwsr-x 4 root staff 4096 Feb 9 01:38 python2.7 drwxrwsr-x 3 root staff 4096 Feb 9 02:11 python3.2 drwxrwsr-x 11 root staff 4096 Mar 22 20:04 .. drwxr-sr-x 3 root staff 4096 Mar 24 01:57 perl -rwxr-xr-x 1 root staff 13350 Apr 3 00:31 libpiface-1.0.so.0.0.0 lrwxrwxrwx 1 root staff 22 Apr 3 00:31 libpiface-1.0.so.0 -> libpiface-1.0.so.0.0.0 lrwxrwxrwx 1 root staff 22 Apr 3 00:31 libpiface-1.0.so -> libpiface-1.0.so.0.0.0 -rwxr-xr-x 1 root staff 976 Apr 3 00:31 libpiface-1.0.la -rw-r--r-- 1 root staff 11128 Apr 3 00:31 libpiface-1.0.a drwxrwsr-x 6 root staff 4096 Apr 3 00:31 . drwxr-sr-x 2 root staff 4096 Apr 3 00:31 pkgconfig root@raspberrypi:/usr/local/lib#

Elvis

On Apr 3, 2013, at 4:51 AM, Blake Jakopovic notifications@github.com wrote:

I've read that creating a symlink can fix the problem (although it is not a permanent solution). You can try

$ sudo ln -s /usr/local/lib/libpiface-1.0.so. libpiface-1.0.so Also, what do you get for

$ uname -a —

Reply to this email directly or view it on GitHub.

elvisimprsntr commented 11 years ago

Any thought of stepping up to FFI 1.6.0 or 1.7.0dev?

Elvis

On Apr 2, 2013, at 10:32 PM, Blake Jakopovic notifications@github.com wrote:

I've installed siriproxy from scratch without errors. Note that I used rbenv instead of rvm.

I expect the problem to be with either

libpiface-1.0 installation (most likely) or user permissions FFI will look for the existence of /usr/local/lib/libpiface-1.0.so, so you can check to see if the file exists.

$ ls /usr/local/lib/ (you should see libpiface-1.0.so) — Reply to this email directly or view it on GitHub.

blakejakopovic commented 11 years ago

I'm working on v0.3 which will have a few breaking changes, as well as update to FFI 1.6.0. I've also added better ffi_lib loading path fallback. I'll see if I can push out a release within the hour.

blakejakopovic commented 11 years ago

I've updated the gem. Note that you will need to uninstall the previous version

$ gem uninstall PiFace

and reinstall it with the new gem name (all lower case)

$ gem install piface

Also, you will need to change all PiFace references to Piface.

The new version uses FFI 1.7.dev.

elvisimprsntr commented 11 years ago

Thanks for the quick response, but no joy. I gotta go pay the bills for now. I'll try again after work.

/usr/local/rvm/gems/ruby-2.0.0-p0/gems/ffi-1.7.0.dev/lib/ffi/library.rb:123:in block in ffi_lib': Could not open library 'libpiface': libpiface: cannot open shared object file: No such file or directory. (LoadError) Could not open library 'libpiface.so': libpiface.so: cannot open shared object file: No such file or directory. Could not open library 'libpiface-1.0': libpiface-1.0: cannot open shared object file: No such file or directory. Could not open library 'libpiface-1.0.so': libpiface-1.0.so: cannot open shared object file: No such file or directory. Could not open library 'libpiface-1.0.so.1': libpiface-1.0.so.1: cannot open shared object file: No such file or directory. Could not open library '/usr/local/lib/libpiface-1.0': /usr/local/lib/libpiface-1.0: cannot open shared object file: No such file or directory from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/ffi-1.7.0.dev/lib/ffi/library.rb:90:inmap' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/ffi-1.7.0.dev/lib/ffi/library.rb:90:in ffi_lib' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/piface-0.3.0/lib/piface/native.rb:6:inmodule:Native' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/piface-0.3.0/lib/piface/native.rb:4:in <module:Piface>' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/piface-0.3.0/lib/piface/native.rb:3:in<top (required)>' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/piface-0.3.0/lib/piface.rb:2:in require' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/piface-0.3.0/lib/piface.rb:2:in<top (required)>' from /root/plugins/siriproxy-piface/lib/siriproxy-piface.rb:1:in require' from /root/plugins/siriproxy-piface/lib/siriproxy-piface.rb:1:in<top (required)>' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/plugin_manager.rb:23:in require' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/plugin_manager.rb:23:inblock in load_plugins' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/plugin_manager.rb:14:in each' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/plugin_manager.rb:14:inload_plugins' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/plugin_manager.rb:8:in initialize' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/command_line.rb:230:innew' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/command_line.rb:230:in init_plugins' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/command_line.rb:89:inrun_server' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/lib/siriproxy/command_line.rb:39:in initialize' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/bin/siriproxy:6:innew' from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/siriproxy-0.5.3/bin/siriproxy:6:in <top (required)>' from /usr/local/rvm/gems/ruby-2.0.0-p0/bin/siriproxy:23:inload' from /usr/local/rvm/gems/ruby-2.0.0-p0/bin/siriproxy:23:in `

' root@raspberrypi:~#

Elvis

On Apr 3, 2013, at 6:17 AM, Blake Jakopovic notifications@github.com wrote:

I've updated the gem. Note that you will need to uninstall the previous version

$ gem uninstall PiFace and reinstall it with the new gem name (all lower case)

$ gem install piface Also, you will need to change all PiFace references to Piface.

The new version uses FFI 1.7.dev.

— Reply to this email directly or view it on GitHub.

elvisimprsntr commented 11 years ago

I had to add the following symbolic link to the /usr/local/lib folder

ln -s libpiface-1.0.so.0.0.0 libpiface-1.0

Not sure which is the right solution, but I opened an issue against the Piface C libraries as well.

https://github.com/thomasmacpherson/piface/issues/7

blakejakopovic commented 11 years ago

Glad you got it working. I haven't played around with FFI much, so I'll have to keep an eye out for fixes.

Here is my /usr/local/lib folder (without the symlink you made to get it working)

/usr/local/lib$ ls -al
-rw-r--r--  1 root staff 11128 Mar 22 17:47 libpiface-1.0.a
-rwxr-xr-x  1 root staff   976 Mar 22 17:47 libpiface-1.0.la
lrwxrwxrwx  1 root staff    22 Mar 22 17:47 libpiface-1.0.so -> libpiface-1.0.so.0.0.0
lrwxrwxrwx  1 root staff    22 Mar 22 17:47 libpiface-1.0.so.0 -> libpiface-1.0.so.0.0.0
-rwxr-xr-x  1 root staff 13350 Mar 22 17:47 libpiface-1.0.so.0.0.0

I've added the libpiface-1.0.so directly to the ffi_lib load paths, so the next release should work automatically.

#piface/lib/piface/native.rb:6
ffi_lib ['libpiface', 'libpiface-1.0', 'libpiface-1.0.so', '/usr/local/lib/libpiface-1.0.so']

If it's a good idea, I might look at packaging the c library with the gem. I'll look into it when I get a chance.

blakejakopovic commented 11 years ago

I've push v0.3.1 which should fix the issue. If you want to delete the symlink, update the gem and let me know if it works.

elvisimprsntr commented 11 years ago

It works! Thanks for the prompt responses. Should I close the Piface C library issue?

blakejakopovic commented 11 years ago

Great :) No problems. I think you can close the Piface C library issue. I'll take a deeper look into the ruby ffi library loading and see if it makes sense for library loading to be more generic.