L
Lionel Thiry
Hello!
I'm on Windows2000, with ruby 1.8.2 (2004-12-25) [i386-mswin32]
(on-click-installer). I have latest mingw and VC++ installed (the
command line version) and vars are set: PATH to each bin dirs, LIB to
each lib dirs and INCLUDE to each include dirs.
I've written in a file the first sample found in pragmatic programmer's
book: http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html
----8<----
#include "ruby.h"
static VALUE t_init(VALUE self)
{
VALUE arr;
arr = rb_ary_new();
rb_iv_set(self, "@arr", arr);
return self;
}
static VALUE t_add(VALUE self, VALUE anObject)
{
VALUE arr;
arr = rb_iv_get(self, "@arr");
rb_ary_push(arr, anObject);
return arr;
}
VALUE cTest;
void Init_Test() {
cTest = rb_define_class("Test", rb_cObject);
rb_define_method(cTest, "initialize", t_init, 0);
rb_define_method(cTest, "add", t_add, 1);
}
----8<----
My first attempt was with the extconf.rb written this way:
----8<----
require 'mkmf'
create_makefile("Test")
----8<----
I launch it, I then launch make (the mingw version of make, I don't have
M$ make. Someone know where I can freely get it?)
And I get this error:
----8<----
----8<----
I'm not a make expert and I feel hard to see where the error truly lies.
I then tried it manually, as I read it on the same pragprog page (with
readaptation for my directory structure):
----8<----
cc1.exe: warning: -fPIC ignored for target (all code is position
independent)
In file included from C:/usr/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:670,
from first_prag_sample.c:1:
C:/usr/ruby/lib/ruby/1.8/i386-mswin32/missing.h:64:1: warning: "isinf"
redefined
In file included from
C:/usr/ruby/lib/ruby/1.8/i386-mswin32/win32/win32.h:56,
from C:/usr/ruby/lib/ruby/1.8/i386-mswin32/defines.h:184,
from C:/usr/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:22,
from first_prag_sample.c:1:
C:/usr/MinGW/include/math.h:290:1: warning: this is the location of the
previous
definition
----8<----
And then the second command line:
----8<----
gcc -shared -o Test.so first_prag_sample.o -lc
C:\usr\MinGW\bin\..\lib\gcc-lib\mingw32\3.2.3\..\..\..\..\mingw32\bin\ld.exe:
cannot find -lc
----8<----
Any clues? Any tips? Perhaps a way to do it easier with rake or rant?
I'm on Windows2000, with ruby 1.8.2 (2004-12-25) [i386-mswin32]
(on-click-installer). I have latest mingw and VC++ installed (the
command line version) and vars are set: PATH to each bin dirs, LIB to
each lib dirs and INCLUDE to each include dirs.
I've written in a file the first sample found in pragmatic programmer's
book: http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html
----8<----
#include "ruby.h"
static VALUE t_init(VALUE self)
{
VALUE arr;
arr = rb_ary_new();
rb_iv_set(self, "@arr", arr);
return self;
}
static VALUE t_add(VALUE self, VALUE anObject)
{
VALUE arr;
arr = rb_iv_get(self, "@arr");
rb_ary_push(arr, anObject);
return arr;
}
VALUE cTest;
void Init_Test() {
cTest = rb_define_class("Test", rb_cObject);
rb_define_method(cTest, "initialize", t_init, 0);
rb_define_method(cTest, "add", t_add, 1);
}
----8<----
My first attempt was with the extconf.rb written this way:
----8<----
require 'mkmf'
create_makefile("Test")
----8<----
I launch it, I then launch make (the mingw version of make, I don't have
M$ make. Someone know where I can freely get it?)
And I get this error:
----8<----
makefile:105: *** multiple target patterns. Stop.make
----8<----
I'm not a make expert and I feel hard to see where the error truly lies.
I then tried it manually, as I read it on the same pragprog page (with
readaptation for my directory structure):
----8<----
first_prag_sample.c -o first_prag_sample.ogcc -fPIC -IC:\usr\ruby\lib\ruby\1.8\i386-mswin32 -g -O2 -c
cc1.exe: warning: -fPIC ignored for target (all code is position
independent)
In file included from C:/usr/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:670,
from first_prag_sample.c:1:
C:/usr/ruby/lib/ruby/1.8/i386-mswin32/missing.h:64:1: warning: "isinf"
redefined
In file included from
C:/usr/ruby/lib/ruby/1.8/i386-mswin32/win32/win32.h:56,
from C:/usr/ruby/lib/ruby/1.8/i386-mswin32/defines.h:184,
from C:/usr/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:22,
from first_prag_sample.c:1:
C:/usr/MinGW/include/math.h:290:1: warning: this is the location of the
previous
definition
----8<----
And then the second command line:
----8<----
gcc -shared -o Test.so first_prag_sample.o -lc
C:\usr\MinGW\bin\..\lib\gcc-lib\mingw32\3.2.3\..\..\..\..\mingw32\bin\ld.exe:
cannot find -lc
----8<----
Any clues? Any tips? Perhaps a way to do it easier with rake or rant?