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
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 <stdio.h> #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 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
You can't use mingw to compile your extensions. You need to use the MS
compiler.
What a pity! I guess this is due to the fact that Microsoft uses a
different executable format than MinGW and the One-Click Installer
happens to be compiled with Microsoft's compiler. I seem to remember
having seen a tool that converts object files between these formats.
Maybe I'll try that one before cobbling together a Microsoft
installation.
5. Copy the directories under 'C:\Program Files\Microsoft Visual C++
Toolkit 2003' to 'C:\Program Files\Microsoft Visual Studio .NET 2003\VC7',
overwriting all the files there. This is recommended because the VC Toolkit
does code optimization, while the .NET SDK does not.
6. Set your environment variables. Run 'C:\Program
Files\Microsoft.NET\SDK\V1.1\bin\sdkvars.bat'. Then run 'C:\Program
Files\Microsoft SDK\setenv.bat'. You can do this permanently through windows
or on a per session basis.
···
On 9/1/05, Axel <anieden@gmx.de> wrote:
Hello, Steve!
Thanks for answering so quickly!
> You can't use mingw to compile your extensions. You need to use the MS
> compiler.
What a pity! I guess this is due to the fact that Microsoft uses a
different executable format than MinGW and the One-Click Installer
happens to be compiled with Microsoft's compiler. I seem to remember
having seen a tool that converts object files between these formats.
Maybe I'll try that one before cobbling together a Microsoft
installation.