From: ruby talk Date: 2006-01-21T13:04:31+09:00 Subject: Re: Extending ruby with c ------=_Part_11469_23289621.1137816257155 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello, i created the .rb [code] require 'mkmf' dir_config("Test") create_makefile("Test") [code] but it only created the makefile which in windows make is not a command. What do i do with the file instead? Becker On 1/20/06, Eero Saynatkari wrote: > > ruby talk wrote: > > I am using the pickaxe example to help learn how it is writen. > > Thank you once again. > > Becker > > > > my run program > > [code] > > require "C:\\ruby\\Test" > > t =3D Test.new() > > t.add("Bill Chase") > > [code] > > > > my code example from pickaxe saved as a .rb > > This here is the problem; the below code must be > saved as a .c file and then compiled to a library > using extconf.rb (the Pickaxe should have further > instructions for this). Once done, you will have > a Test.so file that you can #require for example > from irb. > > > [code] > > #include "ruby.h" > > static VALUE t_init(VALUE self) > > { > > VALUE arr; > > arr =3D rb_ary_new(); > > rb_iv_set(self, "@arr", arr); > > return self; > > } > > > > static VALUE t_add(VALUE self, VALUE anObject) > > { > > VALUE arr; > > arr =3D rb_iv_get(self, "@arr"); > > rb_ary_push(arr, anObject); > > return arr; > > } > > > > VALUE cTest; > > > > void Init_Test() { > > cTest =3D rb_define_class("Test", rb_cObject); > > rb_define_method(cTest, "initialize", t_init, 0); > > rb_define_method(cTest, "add", t_add, 1); > > } > > > > [code] > > > > > > < Error messages elided /> > > The code itself is fine, you just need to compile it. > > > E > > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_11469_23289621.1137816257155--