ruby-vips: Windows problem (ffi-based ruby-vips)

In order to keep https://github.com/jcupitt/ruby-vips/issues/115 clean, I decided to open a new issue for Windows support.

Install instructions for Windows x64:

  • Install Ruby using the RubyInstaller.
  • Set the RUBY_DLL_PATH environment variable to libvips bin directory.
  • Clone the FFI branch with git clone -b ffi-experiment https://github.com/jcupitt/ruby-vips.git
  • Install ruby-vips:
    cd ruby-vips
    gem install bundler
    bundle install
    bundle exec rake install
    
  • Apply this patch (my attempt to load the DLL files).
  • Run a example:
    cd example
    trim8.rb image.png image2.png
    

You’ll see this error:

 (LoadError)4/lib/ruby/gems/2.4.0/gems/ffi-1.9.18-x64-mingw32/lib/ffi/library.rb:147:in `block in ffi_lib': Could not open library 'libvips-42.dll': The specified procedure could not be found.
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ffi-1.9.18-x64-mingw32/lib/ffi/library.rb:100:in `map'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ffi-1.9.18-x64-mingw32/lib/ffi/library.rb:100:in `ffi_lib'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ruby-vips-2.0.0/lib/vips.rb:356:in `<module:Vips>'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ruby-vips-2.0.0/lib/vips.rb:353:in `<top (required)>'
        from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `require'
        from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
        from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:40:in `require'
        from C:/ruby-vips/example/trim8.rb:10:in `<main>'

Tested on 2 different Windows 10 64-bits computer’s, unfortunately the error persists. I’ve opened libvips-42.dll in Dependency Walker to see if I missed some dependencies, but all seems to be ok.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (19 by maintainers)

Commits related to this issue

Most upvoted comments

Good job Kleis! I’ll apply that fix (I’d never heard of :force) and I think we can release 2.0.

omg

/me falls off his chair

I’ve just tested out https://github.com/jcupitt/ruby-vips/commit/17d42c9f5c497186210fe7b9d0148f54da220ff1.

With typedef :ulong, :GType here I still get this error:

(trim8.rb:6948): GLib-GObject-WARNING **: gtype.c:4265: type id '0' is invalid

(trim8.rb:6948): GLib-GObject-WARNING **: can't peek value table for type '<invalid>' which is not currently referenced

(trim8.rb:6948): GLib-GObject-WARNING **: gvalue.c:188: cannot initialize GValue with type '(NULL)', this type has no GTypeValueTable implementation
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ruby-vips-2.0.0/lib/vips/gvalue.rb:136:in `set': unimplemented gtype for set: 0 (Vips::Error)
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ruby-vips-2.0.0/lib/vips/object.rb:129:in `set'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ruby-vips-2.0.0/lib/vips/operation.rb:153:in `set'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ruby-vips-2.0.0/lib/vips/operation.rb:312:in `block in call'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ruby-vips-2.0.0/lib/vips/operation.rb:307:in `each_index'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ruby-vips-2.0.0/lib/vips/operation.rb:307:in `call'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ruby-vips-2.0.0/lib/vips/image.rb:250:in `new_from_file'
        from C:/ruby-vips/example/trim8.rb:12:in `<main>'

Changing it to typedef :uint64, :GType, then everything seems to work fine on Windows x64 (running trim8.rb image.png image2.png will successfully trim the image). 🎉

I didn’t test it out on a 32-bit Windows PC, but I think it will need typedef :uint32, :GType (just like lua-vips and pyvips).