From: Steve Date: 2005-08-31T21:21:24+09:00 Subject: Re: Compiling a Ruby extension You can't use mingw to compile your extensions. You need to use the MS compiler. You can either get a hold of Visual Studio.Net or follow these instructios to cobble together the tools that MS release for free in about 5 different packages. http://www.rubygarden.org/ruby?WindowsCompiler Axel wrote: > Hello! > > I am trying to manually compile a tiny Ruby extension, but finally run > into a problem. I wonder if anyone can give me a hint on what's wrong? > > The code for the extension: > > #include > #include "ruby.h" > __declspec(dllexport) void Init_MyExt(); > static VALUE initialize(VALUE self); > static VALUE perform(VALUE self); > VALUE cMyExt; > void Init_MyExt() { > cMyExt = rb_define_class("MyExt", rb_cObject); > rb_define_method(cMyExt, "initialize", initialize, 0); > rb_define_method(cMyExt, "perform", perform, 0); > } > static VALUE initialize(VALUE self) { > return self; > } > static VALUE perform(VALUE self) { > puts("Here is the C code!"); > return self; > } > > My setup: Windows XP, Ruby One-Click Installer 1.8.2-15, MinGW 3.4.2. > > Now I compile the code above into a DLL: > > gcc -c -IC:\ruby\lib\ruby\1.8\i386-mswin32 myext.c > gcc -shared -o MyExt.dll -Wl,-s myext.o C:\ruby\lib\msvcrt-ruby18.lib > > Now I try to call this DLL via the following client: > > require 'MyExt' > e = MyExt.new > e.perform > > Unfortunatly, this results in the following error message: > > ./MyExt.dll: wrong argument type Fixnum (expected Class) (TypeError) > from > c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in > `require' > from C:/temp/rubyext/test.rb:1 > > Any ideas? >