Forum: wxRuby Cannot load wxruby in IRB

Posted by Mr zengr (zengr)
on 2010-07-07 08:39
Hi,

I am new to ruby and trying to make a simple desktop app using wxruby.

When I do: require 'wx' I get this error:

irb(main):001:0> require 'wx'
LoadError:
dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-1.9.3-universal-darwin/lib/wxruby2.bundle,
9): no suitable image found.  Did find:
  /usr/local/lib/ruby/gems/1.9.1/gems/wxruby-1.9.3-universal-darwin/lib/wxruby2.bundle:
no matching architecture in universal wrapper -
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-1.9.3-universal-darwin/lib/wxruby2.bundle
  from
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-1.9.3-universal-darwin/lib/wx.rb:12:in
`require'
  from
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-1.9.3-universal-darwin/lib/wx.rb:12:in
`<top (required)>'
  from (irb):1:in `require'
  from (irb):1
  from /usr/local/bin/irb:12:in `<main>'

Any suggestions?

Thanks
Posted by Alex Fenton (Guest)
on 2010-07-07 10:46
(Received via mailing list)
Hi

On 07/07/2010 07:39, Utkarsh Sengar wrote:
> I am new to ruby and trying to make a simple desktop app using wxruby.
>    

Welcome.

> When I do: require 'wx' I get this error:
>    

Unfortunately, you can't use wx interactively in irb. A gui app depends
on entering an 'event loop' where it waits for the user to do something.
This will just hang in irb.

> irb(main):001:0>  require 'wx'
> LoadError:
> dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-1.9.3-universal-darwin/lib/wxruby2.bundle,
>    

What OS X version are you on? 1.9.3 is a very old version, the current
release is 2.0.1. You may be on Snow Leopard (10.6) in which case you'll
need to look in the recent m.l. archives for a user-contributed gem -
unfortunately I haven't got the trunk stable to build on this version 
yet.

alex
Posted by Mr zengr (zengr)
on 2010-07-07 11:19
Thanks for the info Alex.

I am running Mac OS X 10.6. I dug up the archives and got the 2.0.1 for 
10.6 here: http://www.ruby-forum.com/topic/199011#905045

I installed the gem:

sudo gem install wxruby-2.0.1-universal-darwin-10.gem

Regarding "require 'wx'" in irb, I was just testing if I will be able to 
use wx in my ruby code or not. I guess, ONLY "require 'wx'" should give 
me a ->true right?

So, after installing 2.0.1 and doing a "require 'wx'", i got this error:

irb(main):001:0> require 'wx'
LoadError: 
dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-10/lib/wxruby2.bundle, 
9): Symbol not found: __ZN10wxCheckBox13MacControlHitEPvS0_
  Referenced from: 
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-10/lib/wxruby2.bundle
  Expected in: flat namespace
 - 
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-10/lib/wxruby2.bundle
  from 
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-10/lib/wx.rb:12:in 
`require'
  from 
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-10/lib/wx.rb:12:in 
`<top (required)>'
  from (irb):1:in `require'
  from (irb):1
  from /usr/local/bin/irb:12:in `<main>'


I get the same error if i do a "require 'wx'" in a .rb file and try to 
run it.

Thanks :)




Alex Fenton wrote:
> Hi
> 
> On 07/07/2010 07:39, Utkarsh Sengar wrote:
>> I am new to ruby and trying to make a simple desktop app using wxruby.
>>    
> 
> Welcome.
> 
>> When I do: require 'wx' I get this error:
>>    
> 
> Unfortunately, you can't use wx interactively in irb. A gui app depends
> on entering an 'event loop' where it waits for the user to do something.
> This will just hang in irb.
> 
>> irb(main):001:0>  require 'wx'
>> LoadError:
>> dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-1.9.3-universal-darwin/lib/wxruby2.bundle,
>>    
> 
> What OS X version are you on? 1.9.3 is a very old version, the current
> release is 2.0.1. You may be on Snow Leopard (10.6) in which case you'll
> need to look in the recent m.l. archives for a user-contributed gem -
> unfortunately I haven't got the trunk stable to build on this version 
> yet.
> 
> alex
Posted by Alex Fenton (Guest)
on 2010-07-07 11:40
(Received via mailing list)
On 07/07/2010 10:19, Mr zengr wrote:
> use wx in my ruby code or not. I guess, ONLY "require 'wx'" should give
> me a ->true right?
>    

Yes. Although ultimately it would be nice to be able to test a GUI
design interactively.

> So, after installing 2.0.1 and doing a "require 'wx'", i got this error:
>
> irb(main):001:0>  require 'wx'
> LoadError:
> dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-10/lib/wxruby2.bundle,
> 9): Symbol not found: __ZN10wxCheckBox13MacControlHitEPvS0_
>    

Sorry, I can't provide support for this gem - I didn't build it.

You may be a bit stuck for getting wxRuby working with the system ruby
provided in 10.6. Apple has made things difficult by moving to 64-bit
architecture, since Carbon (that provides much of wxWidgets 2.8 GUI) is
32-bit only.

I'm using 10.6 and for wxRuby applications I'm using my own 32-bit build
of Ruby 1.9.1. This works just fine with the gems that are downloadable
from Rubyforge. Alternatively I can use the 2.0.1 build by using the
arch command - see following post.

alex
Posted by Mr zengr (zengr)
on 2010-07-08 07:34
Hi Alex,

I checked my ruby version and it was:

ruby 1.9.1p0 (2009-01-20 revision 21700) [i386-darwin10.4.0]

I followed your directions here: http://www.ruby-forum.com/topic/212707 
but it didn't work.

Any suggestions?

Thanks


Alex Fenton wrote:
> On 07/07/2010 10:19, Mr zengr wrote:
>> use wx in my ruby code or not. I guess, ONLY "require 'wx'" should give
>> me a ->true right?
>>    
> 
> Yes. Although ultimately it would be nice to be able to test a GUI
> design interactively.
> 
>> So, after installing 2.0.1 and doing a "require 'wx'", i got this error:
>>
>> irb(main):001:0>  require 'wx'
>> LoadError:
>> dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-10/lib/wxruby2.bundle,
>> 9): Symbol not found: __ZN10wxCheckBox13MacControlHitEPvS0_
>>    
> 
> Sorry, I can't provide support for this gem - I didn't build it.
> 
> You may be a bit stuck for getting wxRuby working with the system ruby
> provided in 10.6. Apple has made things difficult by moving to 64-bit
> architecture, since Carbon (that provides much of wxWidgets 2.8 GUI) is
> 32-bit only.
> 
> I'm using 10.6 and for wxRuby applications I'm using my own 32-bit build
> of Ruby 1.9.1. This works just fine with the gems that are downloadable
> from Rubyforge. Alternatively I can use the 2.0.1 build by using the
> arch command - see following post.
> 
> alex
Posted by Alex Fenton (Guest)
on 2010-07-08 10:10
(Received via mailing list)
On 08/07/2010 06:34, Mr zengr wrote:
> ruby 1.9.1p0 (2009-01-20 revision 21700) [i386-darwin10.4.0]
>
> I followed your directions here: http://www.ruby-forum.com/topic/212707
> but it didn't work.
>    

What happened?
Posted by Mr zengr (zengr)
on 2010-07-08 10:23
Alex Fenton wrote:
> On 08/07/2010 06:34, Mr zengr wrote:
>> ruby 1.9.1p0 (2009-01-20 revision 21700) [i386-darwin10.4.0]
>>
>> I followed your directions here: http://www.ruby-forum.com/topic/212707
>> but it didn't work.
>>    
> 
> What happened?

I am sorry for not detailing the error, when I ran this:

arch -i386 ruby -rubygems ruby-file.rb

I got this error "arch: posix_spawnp: ruby: Bad CPU type in executable"

So, did "uname -m" in my terminal and got i386. So, it seems I am in the 
32bit kernel mode. That's why "ruby --version" also returned 
i386-darwin10.4.0.

So, to summarize:

1. I am running 32bit ruby 1.9.1 on Mac OS X 10.6 Snow Leopard
2. I manually installed wxruby (2.0.1 universal-darwin-9)
3. When I do "require 'wx'" I get this error:

/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-9/lib/wx.rb:12:in 
`require': 
dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-9/lib/wxruby2.bundle, 
9): no suitable image found.  Did find: (LoadError)
  /usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-9/lib/wxruby2.bundle: 
no matching architecture in universal wrapper - 
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-9/lib/wxruby2.bundle
  from 
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-universal-darwin-9/lib/wx.rb:12:in 
`<top (required)>'
  from ruby-file.rb:1:in `require'
  from ruby-file.rb:1:in `<main>'

Thanks a lot for your help!
Posted by Alex Fenton (Guest)
on 2010-07-08 11:29
(Received via mailing list)
On 08/07/2010 09:23, Mr zengr wrote:
> 1. I am running 32bit ruby 1.9.1 on Mac OS X 10.6 Snow Leopard
>    

In that case, there should be no problem - just use the standard gem for
Ruby 1.9:

http://rubyforge.org/frs/download.php/63385/wxruby...

You shouldn't need to mess around with 'arch' b/c both the executable
and gem are simple 32-bit (actually, the gem is dual intel/ppc)

> 2. I manually installed wxruby (2.0.1 universal-darwin-9)
>    

Sounds like you may have installed the gem for Ruby 1.8 by mistake?
Posted by Mr zengr (zengr)
on 2010-07-09 04:31
Alex Fenton wrote:
> On 08/07/2010 09:23, Mr zengr wrote:
>> 1. I am running 32bit ruby 1.9.1 on Mac OS X 10.6 Snow Leopard
>>    
> 
> In that case, there should be no problem - just use the standard gem for
> Ruby 1.9:
> 
> http://rubyforge.org/frs/download.php/63385/wxruby...


I installed this gem and get the same error when I run this 
(http://wxruby.rubyforge.org/wiki/wiki.pl?Getting_Started) sample code 
by:

$ ruby sample.rb

/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-darwin-9/lib/wx.rb:12:in 
`require': 
dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-darwin-9/lib/wxruby2.bundle, 
9): no suitable image found.  Did find: (LoadError)
  /usr/local/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-darwin-9/lib/wxruby2.bundle: 
no matching architecture in universal wrapper - 
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-darwin-9/lib/wxruby2.bundle
  from 
/usr/local/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-darwin-9/lib/wx.rb:12:in 
`<top (required)>'
  from ruby-file.rb:1:in `require'
  from ruby-file.rb:1:in `<main>'


> 
> You shouldn't need to mess around with 'arch' b/c both the executable
> and gem are simple 32-bit (actually, the gem is dual intel/ppc)
> 
>> 2. I manually installed wxruby (2.0.1 universal-darwin-9)
>>    
> 
> Sounds like you may have installed the gem for Ruby 1.8 by mistake?


I am sorry for my never ending problems, I think i will shift to my 
Ubuntu VM.

Thanks
Posted by Alex Fenton (Guest)
on 2010-07-09 13:44
(Received via mailing list)
On 09/07/2010 03:31, Mr zengr wrote:
>    /usr/local/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-darwin-9/lib/wxruby2.bundle:
> no matching architecture in universal wrapper -
>    

Hmm - did you compile your Ruby 1.9 under OS X 10.6? This may be the
mismatch. My ruby 1.9 (which works with the gem) is a version I compiled
before upgrading. There may be some compile flags for Ruby 1.9 to force
arch and 10.5 compatibility. But I don't know what they are.

Can you use Ruby 1.8? If so, the 10.6 system ruby in /usr/bin/ruby
should work with the 1.8 gem, using arch.

> I am sorry for my never ending problems, I think i will shift to my
> Ubuntu VM.
>    

No problem - I blame Apple! Each platform has its own annoyances, 
though.

alex
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.