Code Monkey home page Code Monkey logo

Comments (4)

le0pard avatar le0pard commented on June 23, 2024

The same problem you can see in Travis: https://travis-ci.org/le0pard/webp-ffi

from ffi-compiler.

 avatar commented on June 23, 2024

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'

from ffi-compiler.

le0pard avatar le0pard commented on June 23, 2024

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

from ffi-compiler.

le0pard avatar le0pard commented on June 23, 2024

I found the problem, thanks!

sudo ln -s /usr/local/lib/libwebp.* /usr/lib/

from ffi-compiler.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.