kojix2 / LibUI

A portable GUI library for Ruby
MIT License
208 stars 10 forks source link

`rescue in block in dlload': can't load D:/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/vendor/libui.dll (Fiddle::DLError) #15

Closed kematy closed 3 years ago

kematy commented 3 years ago

D:/Ruby25/lib/ruby/2.5.0/fiddle/import.rb:89:in rescue in block in dlload': can't load D:/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/vendor/libui.dll (Fiddle::DLError) from D:/Ruby25/lib/ruby/2.5.0/fiddle/import.rb:86:inblock in dlload' from D:/Ruby25/lib/ruby/2.5.0/fiddle/import.rb:77:in collect' from D:/Ruby25/lib/ruby/2.5.0/fiddle/import.rb:77:indlload' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/lib/libui/ffi.rb:78:in <module:FFI>' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/lib/libui/ffi.rb:74:in' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/lib/libui/ffi.rb:73:in <top (required)>' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/lib/libui.rb:28:inrequire_relative' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/lib/libui.rb:28:in <module:LibUI>' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/lib/libui.rb:6:in<top (required)>' from D:/Ruby25/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'

kojix2 commented 3 years ago

At first glance, it may be a Fiddle problem.

  1. Can you call Fiddle?
require 'fiddle'
  1. If it does, what version of Fiddle do you have?
require 'fiddle'
p Fiddle::VERSION

The VERSION constant was added recently, so it may not exist. It means that it is prior to 1.0.0.

kojix2 commented 3 years ago

How did you install Ruby on Windows? RubyInstaller?

kematy commented 3 years ago

I install ruby with RubyInstaller. irb(main):001:0> require 'fiddle' => false gem install fiddle Fetching: fiddle-1.0.8.gem (100%) Temporarily enhancing PATH for MSYS/MINGW... Installing required msys2 packages: mingw-w64-i686-libffi 错误:无法打开文件 /var/lib/pacman/local/mingw-w64-i686-gnutls-3.6.13-2/desc: No such file or directory Building native extensions. This could take a while...

kematy commented 3 years ago

in msys2, pacman -Syu update system pacman -S mingw-w64-i686-libffi

then in cmd :gem install fiddle irb(main):001:0> require 'fiddle' => false irb(main):002:0> p Fiddle::VERSION "1.0.8" => "1.0.8"

then

D:/Ruby25/lib/ruby/gems/2.5.0/gems/fiddle-1.0.8/lib/fiddle.rb:67: warning: already initialized constant Fiddle::RTLD_GLOBAL D:/Ruby25/lib/ruby/2.5.0/fiddle.rb:53: warning: previous definition of RTLD_GLOBAL was here D:/Ruby25/lib/ruby/gems/2.5.0/gems/fiddle-1.0.8/lib/fiddle.rb:68: warning: already initialized constant Fiddle::RTLD_LAZY D:/Ruby25/lib/ruby/2.5.0/fiddle.rb:54: warning: previous definition of RTLD_LAZY was here D:/Ruby25/lib/ruby/gems/2.5.0/gems/fiddle-1.0.8/lib/fiddle.rb:69: warning: already initialized constant Fiddle::RTLD_NOW D:/Ruby25/lib/ruby/2.5.0/fiddle.rb:55: warning: previous definition of RTLD_NOW was here D:/Ruby25/lib/ruby/gems/2.5.0/gems/fiddle-1.0.8/lib/fiddle.rb:61:in initialize': Exec format error (Fiddle::DLError) from D:/Ruby25/lib/ruby/gems/2.5.0/gems/fiddle-1.0.8/lib/fiddle.rb:61:innew' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/fiddle-1.0.8/lib/fiddle.rb:61:in dlopen' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/fiddle-1.0.8/lib/fiddle/import.rb:86:inblock in dlload' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/fiddle-1.0.8/lib/fiddle/import.rb:77:in collect' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/fiddle-1.0.8/lib/fiddle/import.rb:77:indlload' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/lib/libui/ffi.rb:78:in <module:FFI>' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/lib/libui/ffi.rb:74:in' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/lib/libui/ffi.rb:73:in <top (required)>' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/lib/libui.rb:28:inrequire_relative' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/lib/libui.rb:28:in <module:LibUI>' from D:/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/lib/libui.rb:6:in<top (required)>' from D:/Ruby25/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in require' from D:/Ruby25/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:inrescue in require' from D:/Ruby25/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in require' from D:/ruby-lab/guis/libui.rb:1:in

'

kojix2 commented 3 years ago

Thanks.

Sorry, It doesn't seem to be a fiddle problem. It seems that libui.dll cannot be loaded. LibUI problem.

First, we need to find out if libui.dll exists.

/Ruby25/lib/ruby/gems/2.5.0/gems/libui-0.0.8/vendor/libui.dll

image image

Check the file size and make sure the file is not corrupt. image

kematy commented 3 years ago

Only ofr 64 bit Ruby? 答复111

kojix2 commented 3 years ago

Only the 64bit version is packed in the Gem. (´-ω-`) Other versions are distributed on the libui site. If you replace it, it might work.

https://github.com/andlabs/libui/releases/tag/alpha4.1

kematy commented 3 years ago

Thank you

kojix2 commented 3 years ago

Now I can reproduce the issue.

Ruby libui.dll work?
Ruby+Devkit 2.5.9-1 (x86) libui-alpha4.1-windows-amd64-shared.zip Not work
Ruby+Devkit 2.5.9-1 (x86) libui-alpha4.1-windows-386-shared.zip OK

Thank you for your report. If there are no further problems, please close it.

kojix2 commented 3 years ago

Updates Added a task to the Rakefile to download the 32-bit libui shared library.

rake vendor:all_x64      # Download libui.so, libui.dylib, and libui.dll to...
rake vendor:linux_x64    # Download libui.so for Linux to vendor directory
rake vendor:linux_x86    # Download libui.so for Linux to vendor directory
rake vendor:mac_x64      # Download libui.dylib for Mac to vendor directory
rake vendor:windows_x64  # Download libui.dll for Windows to vendor directory
rake vendor:windows_x86  # Download libui.dll for Windows to vendor directory

So, you can install it as follows

rake vendor:windows_x86
rake install
rubyFeedback commented 2 years ago

Oddly enough I re-installed the Win10 laptop and I ran into the exact same issue.

The strange thing is that prior to the re-installation, that issue did not happen.

Right now I am a bit confused how this error shows up. I don't recall what I did different prior to the reinstall; always installed via "gem install libui".

Note that require 'fiddle' and Fiddle::VERSION works. But require 'libui' fails with a "No such file or directory" Fiddle::DLError.

Is there some path issue perhaps? I can start "irb" from cmd.exe just fine and "ruby -v" shows the most recent ruby version (which is ruby 3.0.3).

kojix2 commented 2 years ago

@rubyFeedback Please tell us a little more about your environment. Did you use RubyInstaller to install Ruby, and is Ruby really a 64-bit version? Obviously using a 32bit version of Ruby will cause problems, but other causes are less clear and need to be investigated.

kojix2 commented 2 years ago

One way to tell 64bit Ruby from 32bit Ruby is to use ruby -e "puts 1.size"

If it is 4, it is 32-bit, and if it is 8, it is 64-bit.