From: Lyle Johnson Date: 2002-03-28T03:09:47+09:00 Subject: Re: Ruby SWIG problems > I've been trying to use Ruby SWIG, but been having limited success. > Currently I'm using SWIG 1.3.11, and Ruby 1.7.2 ('stable' ruby versions have > given me even less success than below). Here's the scoop: <... file listings snipped ...> > ...and i run the following commands, all via cygwin (Ruby & SWIG both also > compiled using cygwin): > > $ swig -c++ -ruby example.i > $ gcc -c example.cxx > $ gcc -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i386-cygwin > $ gcc -shared example.o example_wrap.o -o example.so -lcygwin-ruby17 > > ... all with no errors. Now when i try and use my new module 'example' - i > get this: > > $ irb > TypeError: wrong argument type Fixnum (expected Class) > from (irb):1:in `require' > from (irb):1 > irb(main):002:0> > > Anyone have any ideas? I've tried using different class definitions, etc etc > but with no joy. You need to compile example_wrap.cxx (i.e. the SWIG-generated wrapper code) with the -DUSEIMPORTLIB flag, i.e. $ gcc -DUSEIMPORTLIB -c example_wrap.cxx -I/usr/local/lib/1.6/i386-cygwin This, by the way, has nothing to do with SWIG per se; it's just a requirement for compiling code that you're going to link against the Ruby DLL. On a side note, if you have the time you may also wish to check the development version of SWIG out from CVS (see http://www.swig.org/cvs.html for instructions on how to do so). We've made a number of improvements and bug fixes for the SWIG Ruby module since the SWIG 1.3.11 release. Hope this helps, Lyle