From: Shashank Date Date: 2003-06-25T13:34:50+09:00 Subject: help needed: extending ruby I'm trying out the following example from the book "Making use of Ruby" (page 200,201): #----- tst_simple.rb ------------ require 'simple' s = Simple.new(123) p s.i p s.a s.i = 456 s.a.push("Hello") s.a.push("World") p s.a #----------------------------- where the class Simple is defined using the C extension shown below. I compiled it using VC++ 6.0 on Win XP Pro and got no warning or errors. Then I copied the resulting "simple.dll" in C:\ruby\lib\ruby\site_ruby. But when I ran the ruby code I get: C:/ruby/lib/ruby/site_ruby/simple.dll: 126: The specified module could not be found. - C:/ruby/lib/ruby/site_ruby/simple.dll (LoadError) from C:/atest/tst_simple.rb:1 What am I missing ? //--------------------------------------------------------------------- #include static VALUE simple_initialize(VALUE self, int iValue) { rb_iv_set(self,"@i",iValue); rb_iv_set(self,"@a",rb_ary_new()); return self; } static VALUE simple_get_i(VALUE self) { return rb_iv_get(self,"@i"); } static VALUE simple_set_i(VALUE self, int iValue) { return rb_iv_set(self,"@i",iValue); } static VALUE simple_get_a(VALUE self) { return rb_iv_get(self,"@a"); } void Init_Simple() { VALUE cSimple; cSimple = rb_define_class("Simple",rb_cObject); rb_define_method(cSimple,"initialize",simple_initialize,1); rb_define_method(cSimple,"i", simple_get_i, 0); rb_define_method(cSimple,"i=", simple_set_i, 1); rb_define_method(cSimple,"a", simple_get_a, 0); } //--------------------------------------------------------------------- Please help. Thanks, -- shanko