Closed le0pard closed 11 years ago
The same problem you can see in Travis: https://travis-ci.org/le0pard/webp-ffi
It looks like WebPGetInfo() is defined in libwebp, and not in your library.
It also looks like linux does not re-export symbols from shared lib dependencies when building that shared lib.
What you need to do, is explicitly load libwebp via FFI, as well as your wrapper.
You can either use another module, and extend FFI::Library inside it, then ffi_lib, attach_function, etc, OR you can just tack it on to the end of your ffi_lib call.
e.g.
ffi_lib FFI::Compiler::Loader.find('webp_ffi'), 'webp'
Thanks, but right now I have another error:
$ rake
rm -r ext/webp_ffi/x86_64-linux/util.o
rm -r ext/webp_ffi/x86_64-linux/webp_ffi.o
rm -r ext/webp_ffi/x86_64-linux/libwebp_ffi.so
rm -r ext/webp_ffi/x86_64-linux/libwebp_ffi.so
rm -r ext/webp_ffi/x86_64-linux/util.o
rm -r ext/webp_ffi/x86_64-linux/webp_ffi.o
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -fPIC -DHAVE_PUTS=1 -DHAVE_STDIO_H=1 -o ext/webp_ffi/x86_64-linux/util.o -c ext/webp_ffi/util.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -fPIC -DHAVE_PUTS=1 -DHAVE_STDIO_H=1 -o ext/webp_ffi/x86_64-linux/webp_ffi.o -c ext/webp_ffi/webp_ffi.c
gcc -shared -o ext/webp_ffi/x86_64-linux/libwebp_ffi.so ext/webp_ffi/x86_64-linux/util.o ext/webp_ffi/x86_64-linux/webp_ffi.o -fexceptions -lz -lwebp
/home/vagrant/.rvm/rubies/ruby-2.0.0-p0/bin/ruby -S rspec ./spec/webp_ffi_spec.rb
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/gems/ffi-1.4.0/lib/ffi/library.rb:123:in `block in ffi_lib': Could not open library 'webp': webp: cannot open shared object file: No such file or directory. (LoadError)
Could not open library 'libwebp.so': libwebp.so: cannot open shared object file: No such file or directory
from /home/vagrant/.rvm/gems/ruby-2.0.0-p0/gems/ffi-1.4.0/lib/ffi/library.rb:90:in `map'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p0/gems/ffi-1.4.0/lib/ffi/library.rb:90:in `ffi_lib'
from /vagrant/lib/webp_ffi.rb:7:in `<module:C>'
from /vagrant/lib/webp_ffi.rb:5:in `<module:WebpFfi>'
from /vagrant/lib/webp_ffi.rb:4:in `<top (required)>'
from /vagrant/spec/spec_helper.rb:3:in `require'
from /vagrant/spec/spec_helper.rb:3:in `<top (required)>'
from /vagrant/spec/webp_ffi_spec.rb:1:in `require'
from /vagrant/spec/webp_ffi_spec.rb:1:in `<top (required)>'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.13.0/lib/rspec/core/configuration.rb:819:in `load'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.13.0/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.13.0/lib/rspec/core/configuration.rb:819:in `each'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.13.0/lib/rspec/core/configuration.rb:819:in `load_spec_files'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.13.0/lib/rspec/core/command_line.rb:22:in `run'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.13.0/lib/rspec/core/runner.rb:80:in `run'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.13.0/lib/rspec/core/runner.rb:17:in `block in autorun'
rake aborted!
/home/vagrant/.rvm/rubies/ruby-2.0.0-p0/bin/ruby -S rspec ./spec/webp_ffi_spec.rb failed
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.13.0/lib/rspec/core/rake_task.rb:156:in `run_task'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.13.0/lib/rspec/core/rake_task.rb:124:in `block (2 levels) in initialize'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.13.0/lib/rspec/core/rake_task.rb:122:in `block in initialize'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `eval'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => default => spec
(See full trace by running task with --trace)
But library exist:
$ ls -la /usr/local/lib/
total 4504
drwxr-xr-x 5 root root 4096 Mar 8 11:53 .
drwxr-xr-x 10 root root 4096 Jun 5 2012 ..
-rw-r--r-- 1 root root 2914584 Mar 8 11:53 libwebp.a
-rwxr-xr-x 1 root root 956 Mar 8 11:53 libwebp.la
lrwxrwxrwx 1 root root 16 Mar 8 11:53 libwebp.so -> libwebp.so.4.0.1
lrwxrwxrwx 1 root root 16 Mar 8 11:53 libwebp.so.4 -> libwebp.so.4.0.1
-rwxr-xr-x 1 root root 1669468 Mar 8 11:53 libwebp.so.4.0.1
drwxr-xr-x 2 root root 4096 Mar 8 11:53 pkgconfig
drwxrwsr-x 4 root staff 4096 Mar 8 11:02 python2.7
drwxr-xr-x 3 root root 4096 Mar 8 11:42 site_ruby
I found the problem, thanks!
sudo ln -s /usr/local/lib/libwebp.* /usr/lib/
I have issue with https://github.com/le0pard/webp-ffi. Writting library by using ffi and ffi-compiler. Check my library by rspec.
My Rackfile:
Running on Mac OS:
And running on Ubuntu 12.04:
What my configuration is invalid? I coudn't find problem. Thanks in advance.
P.S. If you want test my lib you should install Web-P lib https://developers.google.com/speed/webp/docs/compiling