Hi,

I've managed to build the SWIG/Ruby examples using VC6.0 and have been in
contact with the maintainer of the SWIG/Ruby section to get then working in
the current distribution of SWIG. Here's the relevent snippet from the mail
I sent to him describing how to compile SWIG/Ruby:

============================================================================
================= 

I've got all the examples working. You're right about using vc from
the command line. I finally tried using the method described in the
SWIG Ruby Examples page. I'm using ruby 1.6.5 compiled using VC. This
seems to be important as installing this version sets a number of
environment variables that are used in the makefile generated by Ruby.

Here's the steps I used:

First set the vc environment vars:

E:\otherscode\SWIG-1.3.9\Examples\ruby\simple>vcvars32.bat

Build the interface:
E:\otherscode\SWIG-1.3.9\Examples\ruby\simple>swig -ruby
-I\otherscode\swig-1.3.9\lib -I\otherscode\swig-1.3.9\lib\ruby example.i

I had to add the paths to the swig libs manually as I am using the
precompiled windows swig binary.

Create a file called extconf.rb that looks like the following:
require 'mkmf'
create_makefile('example')

Build the makefile:
E:\otherscode\SWIG-1.3.9\Examples\ruby\simple>ruby extconf.rb

Make:
E:\otherscode\SWIG-1.3.9\Examples\ruby\simple>nmake

Run the ruby test
E:\otherscode\SWIG-1.3.9\Examples\ruby\simple>ruby run.rb

So using this method the only changes that have to be made to the
distribution is to add the extconf.rb file to each of the examples.
There is also no need to add #include <malloc.h> to the wrapper.

When compiling any of the examples that have the VALUEFUNC macro I
recieved this error message:
This conversion requires a reinterpret_cast, a C-style cast or
function-style cast
example_wrap.cxx(572) : error C2664: 'rb_define_method' : cannot convert
parameter 3 from 'unsigned long (__cdecl *)(...
)' to 'unsigned long (__cdecl *)(void)'

This can be fixed by putting a cast to (unsigned long
(__cdecl*)(void)) in front of the VALUEFUNC but this should be fixed
in the code generator I guess.

If you could give this a try and let me know how you get on that'd be
great.

regards,

Martin 
============================================================================
==

Hope that's helpful,


Martin

-----Original Message-----
From: MikkelFJ [mailto:mikkelj-anti-spam / post1.dknet.dk]
Sent: Wednesday, 5 December 2001 10:44 AM
To: ruby-talk / ruby-lang.org
Subject: [ruby-talk:27494] Ruby SWIG alive?


I justed tried to use Ruby SWIG.
It was easy enough, but the code generated is not ANSI C and it doesn't
compile on Windows (MSVC 6.0).
This is mainly due to the use of ALLOCA_N, and some missing typecasts.
ALLOCA_N is defined as alloca.

When I check the buglist on source forge, there is no Ruby entry but there
are a few bugs on Ruby that doesn't seem to be maintained.
When I look at the Ruby SWIG homepage via RAA it states that the version at
the site is not maintained.
Does this mean that Ruby SWIG is not maintained?

That would be a pitty, because I was just so pleased about how well it
seemed to work.

MikkelFJ