# Cannot require 'wx'

**URL:** <https://www.ruby-forum.com/t/cannot-require-wx/193550>\
**Category:** wxRuby\
**Created:** [August 19, 2010, 3:26pm UTC](https://www.ruby-forum.com/t/cannot-require-wx/193550 "2010-08-19T15:26:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tutiplain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tutiplain](https://www.ruby-forum.com/u/tutiplain)\
**Post date:** [August 19, 2010, 3:26pm UTC](https://www.ruby-forum.com/t/cannot-require-wx/193550/1 "2010-08-19T15:26:04Z")

</div>

Hi everyone,

I’m new to wxRuby. I installed using “gem install wxruby” and it  
installed version 2.0.1, along with ri and rdoc documentation. I try  
to test it in irb, but I get this message:

```auto
irb(main):001:0> require 'wx'
LoadError: no such file to load -- wx
        from (irb):1:in `require'
        from (irb):1
```

I also get an error message if I write this code in a text editor:

```auto
require "wx"
include Wx

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

MinimalApp.new.main_loop
```

Produces this:

```auto
./wx.rb:2: uninitialized constant Wx (NameError)
        from wx.rb:1:in `require'
        from wx.rb:1
```

I thought it had something to do with the wx\_sugar gem so I  
uninstalled it using “gem uninstall wx\_sugar”, but the errors were still  
there. I am using Win XP Professional, and Ruby Installer 1.8.7.  
Please help!

---

<div class="post-metadata">

**Author:** ![tutiplain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tutiplain](https://www.ruby-forum.com/u/tutiplain)\
**Post date:** [August 19, 2010, 4:25pm UTC](https://www.ruby-forum.com/t/cannot-require-wx/193550/2 "2010-08-19T16:25:36Z")

</div>

I believe you have to require rubygems before you require wx

---

<div class="post-metadata">

**Author:** ![tutiplain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tutiplain](https://www.ruby-forum.com/u/tutiplain)\
**Post date:** [August 19, 2010, 5:15pm UTC](https://www.ruby-forum.com/t/cannot-require-wx/193550/3 "2010-08-19T17:15:43Z")

</div>

Bruce Loving wrote:

> I believe you have to require rubygems before you require wx

Hi, I did as you suggested and got the following:

NameError: uninitialized constant Wx  
from ./wx.rb:2  
from  
C:/Ruby187/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:31:in  
`gem_original_require' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’

This was using irb.

---

<div class="post-metadata">

**Author:** ![tutiplain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tutiplain](https://www.ruby-forum.com/u/tutiplain)\
**Post date:** [August 19, 2010, 5:22pm UTC](https://www.ruby-forum.com/t/cannot-require-wx/193550/4 "2010-08-19T17:22:21Z")

</div>

Hi,

I tried using Ruby Installer 1.8.6 and now it works (after requiring  
rubygems as you suggested). It seems wxruby is incompatible with the  
newer versions. They should put that in the tutorial.

Anyhoop, thanks so much. Now I can begin programming GUI in Ruby!

---

<div class="post-metadata">

**Author:** ![tutiplain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tutiplain](https://www.ruby-forum.com/u/tutiplain)\
**Post date:** [August 19, 2010, 5:51pm UTC](https://www.ruby-forum.com/t/cannot-require-wx/193550/5 "2010-08-19T17:51:41Z")

</div>

this works just fine for me.  
require ‘rubygems’  
require ‘wx’  
include Wx

---

<div class="post-metadata">

**Author:** ![tutiplain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tutiplain](https://www.ruby-forum.com/u/tutiplain)\
**Post date:** [August 20, 2010, 12:11am UTC](https://www.ruby-forum.com/t/cannot-require-wx/193550/6 "2010-08-20T00:11:44Z")

</div>

Thanks for the explanation Mario,

> You will find with our next wxRuby gem release, that it will be compiled  
> for  
> MINGW and GCC 4.0+. And then we’ll have to provide deprecated versions  
> for  
> older GCC Versions. I don’t know if we will still maintain a MSVCRT  
> version  
> for Windows, as that has not been decided yet.
> 
> hth,
> 
> Mario

I did not completely understand what you meant with this paragraph but  
I assume that you mean the next release will be compatible without  
requiring a separate build. I look forward to it.

I do remember downloading a wx-ready ruby 1.9 installer from the  
wxRuby page in RubyForge a while back. Not sure if it’s still  
available. But I didn’t use it for long. Anyway, I’ll check it out  
again. In the meantime, I’m happy with 1.8.6.

---

<div class="post-metadata">

**Author:** ![tutiplain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tutiplain](https://www.ruby-forum.com/u/tutiplain)\
**Post date:** [August 19, 2010, 10:31pm UTC](https://www.ruby-forum.com/t/cannot-require-wx/193550/7 "2010-08-19T22:31:34Z")

</div>

Heya Tuti,

We provide a Installer program on our Projects page of RubyForge for  
Ruby  
1.8.7, and wxRuby combined. The reason we have troubles with this, is  
cause  
the Ruby Installer project just went from MSVCRT compiler to the MINGW  
compiler. Different compilers have different methods in which to  
compile  
code, and export Library Routines, so binary extensions built for  
MSVCRT,  
isn’t compatible with MINGW. The same holds true on Ubuntu systems.  
Ubuntu  
version 8.10 and before earlier use gcc 3.3, which is incompatible with  
Ubuntu version 9.04 onwards, which uses gcc 4.0. We have to use  
different  
builds for \< 8.10 compared to \> 9.04.

The main cause of this, is RubyGems isn’t very compiler aware, outside  
of  
the main compiler names, they don’t allow for Compiler versions in the  
naming scheme. So we have to package things a bit differently. In most  
cases, when you try to install a binary Gem, it won’t follow the  
compiler  
used, especially MINGW, as it just recently became popular with  
the adaptation of the Ruby O. Click Installer project.

You will find with our next wxRuby gem release, that it will be compiled  
for  
MINGW and GCC 4.0+. And then we’ll have to provide deprecated versions  
for  
older GCC Versions. I don’t know if we will still maintain a MSVCRT  
version  
for Windows, as that has not been decided yet.

hth,

Mario
