# Help building wxRuby with VC8

**URL:** <https://www.ruby-forum.com/t/help-building-wxruby-with-vc8/164553>\
**Category:** wxRuby\
**Created:** [April 2, 2009, 3:26pm UTC](https://www.ruby-forum.com/t/help-building-wxruby-with-vc8/164553 "2009-04-02T15:26:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_MuSSSSoz\_Ara](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47c2d/32.png) [@Miguel\_MuSSSSoz\_Ara](https://www.ruby-forum.com/u/Miguel_MuSSSSoz_Ara)\
**Post date:** [April 2, 2009, 3:26pm UTC](https://www.ruby-forum.com/t/help-building-wxruby-with-vc8/164553/1 "2009-04-02T15:26:43Z")

</div>

Hello,

I’m trying to build wxRuby-2.0.0 with Ruby 1.9.1-p0 and SWIG 1.3.39  
using VC8, but so far I didn’t manage to do it. First of all, is there  
some information available online for building wxRuby with Visual  
Studio?

Up to now I’ve found three problems: one that I could solve, another  
that I could avoid and a third one that blocked me completely  
(Goldilocks and the Three Compiler Errors! - ok, no more jokes, I  
promise). I’d be grateful if anyone could help me with these problems.

The first problem was with a wxWidgets include file, “wx/filefn.h”. When  
compiling wxRuby, the following error was shown:

error C2628: ‘\_off\_t’ followed by ‘\_\_int64’ is ilegal

I found online a solution for this, but I don’t know if it’s the correct  
one. See [Trouble compiling wxWindows plugin in Visual C++ 7.1 - The VideoLAN Forums](http://forum.videolan.org/viewtopic.php?f=2&t=792). In filefn.h,  
add the condition !defined(\_OFF\_T\_DEFINED) before the definition of  
off\_t. The modified code is:

#if (!defined(\_OFF\_T\_DEFINED) && defined( **VISUALC** ) &&  
!defined( **WXWINCE** )) || ( defined( **MWERKS** ) && defined( **INTEL** ) )  
typedef \_off\_t off\_t;  
…  
#endif

The second problem was that the class wxGLCanvas was not defined when  
compiling wxRuby. I edited manually the GLCanvas.cpp file generated by  
SWIG and added “#define wxUSE\_GLCANVAS 1”. Could you tell me what is the  
correct place to set this option?

And finally, the third problem is that when building wxRuby with Rake  
some classes cannot be found by fixmodule.rb. I get the following  
message:

Class: AboutDialogInfo  
ERROR! swig/fixmodule.rb Didn’t find swig class  
rake aborted!  
Command failed with status (1): [ruby swig/fixmodule.rb  
src/AboutDialogInfo…]

I tried to modify fixmodule.rb and got everything to compile, but then  
the linking failed with many undefined references to extern symbols like  
cWxToplevelWindow. What am I doing wrong?

I don’t think it’s related, but I’m using a version of Rake built with  
Ruby 1.8.6 and I’m trying to build wxRuby for Ruby 1.9.1.

Thanks in advance for your help.  
Best regards,

Miguel

---

<div class="post-metadata">

**Author:** ![Miguel\_MuSSSSoz\_Ara](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47c2d/32.png) [@Miguel\_MuSSSSoz\_Ara](https://www.ruby-forum.com/u/Miguel_MuSSSSoz_Ara)\
**Post date:** [April 4, 2009, 9:00am UTC](https://www.ruby-forum.com/t/help-building-wxruby-with-vc8/164553/2 "2009-04-04T09:00:03Z")

</div>

Hi,

2009/4/2 Miguel Muñoz Arancón [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Hello,
> 
> I’m trying to build wxRuby-2.0.0 with Ruby 1.9.1-p0 and SWIG 1.3.39 using  
> VC8, but so far I didn’t manage to do it. First of all, is there some  
> information available online for building wxRuby with Visual Studio?

Your configuration is not (yet?) supported.

Currently on Windows :

- wxRuby-2.0 with ruby-1.8 can be built without any problems with VC6  
and VC7.1
- wxRuby-2.0 with ruby-1.9 cannot be built with any version of VC
- wxRuby-2.0 with ruby-1.8 or ruby-1.9 can be built with MinGW

The wxRuby team currently favors MinGW build for Windows.

> #if (!defined(\_OFF\_T\_DEFINED) && defined( **VISUALC** ) &&  
> !defined( **WXWINCE** )) || ( defined( **MWERKS** ) && defined( **INTEL** ) )  
> typedef \_off\_t off\_t;  
> …  
> #endif

I’ll try that.

> The second problem was that the class wxGLCanvas was not defined when  
> compiling wxRuby. I edited manually the GLCanvas.cpp file generated by SWIG  
> and added “#define wxUSE\_GLCANVAS 1”. Could you tell me what is the correct  
> place to set this option?

It seems that you have not built wxWidgets appropriately.  
See [http://wxruby.rubyforge.org/wiki/wiki.pl?HowToBuildWxWidgets](http://wxruby.rubyforge.org/wiki/wiki.pl?HowToBuildWxWidgets) for  
build instructions of wxWidgets.

Cheers.

Chauk-Mean.

---

<div class="post-metadata">

**Author:** ![Miguel\_MuSSSSoz\_Ara](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47c2d/32.png) [@Miguel\_MuSSSSoz\_Ara](https://www.ruby-forum.com/u/Miguel_MuSSSSoz_Ara)\
**Post date:** [April 8, 2009, 8:05am UTC](https://www.ruby-forum.com/t/help-building-wxruby-with-vc8/164553/3 "2009-04-08T08:05:11Z")

</div>

> From: Chauk-Mean P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Thanks for your answer.

> > I’m trying to build wxRuby-2.0.0 with Ruby 1.9.1-p0 and SWIG 1.3.39 using  
> > VC8, but so far I didn’t manage to do it. First of all, is there some  
> > information available online for building wxRuby with Visual Studio?
> 
> Your configuration is not (yet?) supported.

I was afraid of this. Unfortunately I cannot change to MinGW because I  
need  
to interface with a C++ application that I cannot port.

I know that this is not the list to discuss it, but I miss in Ruby  
something like  
Tcl’s stubs: the interpreter exposes its API through a table of function  
pointers  
so that binary extensions are compatible across different versions of  
the  
interpreter. This would be very useful for a project like wxRuby.

> > The second problem was that the class wxGLCanvas was not defined when  
> > compiling wxRuby. I edited manually the GLCanvas.cpp file generated by SWIG  
> > and added “#define wxUSE\_GLCANVAS 1”. Could you tell me what is the correct  
> > place to set this option?
> 
> It seems that you have not built wxWidgets appropriately.  
> See [http://wxruby.rubyforge.org/wiki/wiki.pl?HowToBuildWxWidgets](http://wxruby.rubyforge.org/wiki/wiki.pl?HowToBuildWxWidgets) for  
> build instructions of wxWidgets.

Aha! I hadn’t see this page. This fixes the wxGLCanvas problem.

> > Class: AboutDialogInfo  
> > ERROR! swig/fixmodule.rb Didn’t find swig class

Regarding the third problem, it seems that fixmodule.rb looks for some  
declarations  
of swig\_class variables that don’t exist. It seems that they are not  
generated at  
all by SWIG, so there could be some problem before VC8 does anything.  
Which  
exact version of SWIG is proven to work with wxRuby? (The build  
instructions say  
only “any recent version”).

In case that it’s useful to diagnose my problem, I’ll add some more  
information. I  
got wxRuby 2.0.0 to build against Ruby 1.8.7 with the following  
modifications:

- remove the call to fixmodule.rb in rake/rakewx.rb; this script looks  
for declarations  
like “swig\_class cXXXXX” that are not extern, but there are no such  
declarations in  
my SWIG generated code.

- add some variable declarations in swig/wx.i:  
swig\_class cWxWindow;

swig\_class cWxTopLevelWindow;

swig\_class cWxSize;

swig\_class cWxEvent;

swig\_class cWxEvtHandler;

I installed wxRuby and set the executable manifest as explained in the  
wiki, but  
when I run “require ‘Wx’” the interpreter crashes with an unhandled  
exception, so  
obviously that’s not the correct solution.

Cheers,

Miguel

---

<div class="post-metadata">

**Author:** ![Miguel\_MuSSSSoz\_Ara](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47c2d/32.png) [@Miguel\_MuSSSSoz\_Ara](https://www.ruby-forum.com/u/Miguel_MuSSSSoz_Ara)\
**Post date:** [April 15, 2009, 1:27am UTC](https://www.ruby-forum.com/t/help-building-wxruby-with-vc8/164553/4 "2009-04-15T01:27:51Z")

</div>

Hi Miguel

Sorry for being slow to reply. I think you might be onto something with  
SWIG versions…

Miguel Muñoz Arancón wrote:

> > Your configuration is not (yet?) supported.
> 
> I was afraid of this. Unfortunately I cannot change to MinGW because I  
> need  
> to interface with a C++ application that I cannot port.

That’s a shame. As I mentioned in another email, I’m open to working on  
supporting MSVC9 if it becomes clear that that’s the preferred basis for  
Ruby 1.9 on Windows.

> instructions say  
> only “any recent version”).

Rake should test that you have a recent enough version of SWIG to work  
with your version of Ruby - it’s near the top of wxRuby’s rakefile  
(SWIG\_MINIMUM\_VERSION).

I just had a look at SWIG’s website and they’ve released versions 1.3.38  
and 1.3.39 since wxRuby 2.0 was released. I did a quick diff on the ruby  
changes and they look significant enough that these new versions might  
break wxRuby. I would strongly suggest dropping back to 1.3.37 and  
seeing if that helps.

We used to test for SWIG\_MAXIMUM\_VERSION as SWIG makes no guarantees  
about backwards or forwards compatibility between versions. I guess we  
may need to go back to this.

> exception, so  
> obviously that’s not the correct solution.

As you guessed, the kind of error “no class found” you’re getting from  
fixmodule.rb is a sign that something has gone wrong in generating the  
code for that class - it’s either a SWIG version problem or something  
that needs fixing elsewhere.

alex
