Search code examples
rubyuser-interfacepathrubygemswxruby

Problem using wxRuby


I am trying to create my first GUI using wxRuby. I installed wxRuby (using gem install wxruby-ruby19) and, it seemed to be installed alright. I copied some code directly from the wxRuby site. Here is the code I used:

test.rb

require "wx"
include Wx

class MinimalApp < App
  def on_init
    Frame.new(nil, -1, "The Bare Minimum").show()
  end
end

MinimalApp.new.main_loop

When I ran it, I got this error:

<internal:lib/rubygems/custom_require>:29:in `require': libwx_gtk2u_stc-2.8.so.0: cannot open shared object file: No such file or directory - /usr/local/ruby/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-linux/lib/wxruby2.so (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-linux/lib/wx.rb:12:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:33:in `require'
from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from test.rb:2:in `<main>'

I thought it was saying that wxruby wasn't in that directory, but I checked and it was, so I'm not sure what the problem is. If anyone could help, that would be awesome.


Solution

  • To use wxRuby you need wxWidgets installed (wxGTK in your case). The problem is wxRuby uses the wxWidgets shared libraries (e.g. libwx_gtk2u_stc-2.8.so.0) and it cant find them.