----Next_Part(Fri_Jan__7_23:35:40_2000_886)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

SWIG/Ruby勉強中のやすしです。

とりあえず swigの tarballに入っている documentを読みながら、swigrubyを使っ
ているのですが、どうやら rubyの extensionを發任弔泙鼎い討泙造卒

$ ruby extconf.rb 
creating Makefile

$ make
gcc -fPIC -I/usr/local/lib/ruby/1.4/i586-linux -O6 -fPIC \
   -I/usr/local/include    -c foo.c -o foo.o
gcc -shared   -o foo.so foo.o -lc 

$ ruby -I. foo.rb 
./foo.rb:2: uninitialized constant Foo (NameError)
	from foo.rb:1:in `require'
	from foo.rb:1

なにを忘れているんでしょうか‥‥‥‥。

Init_foo()って、require 'foo'で呼ばれるんじゃなかったっけ‥。

$ uname -a
Linux yashipc 2.2.13 #2 Sun Dec 26 13:57:17 EST 1999 i586 unknown
$ ruby -v
ruby 1.4.3 (1999-12-08) [i586-linux]
--
          yashi

----Next_Part(Fri_Jan__7_23:35:40_2000_886)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="extconf.rb"

require 'mkmf'

have_library('c', 'printf')
create_makefile 'foo'

----Next_Part(Fri_Jan__7_23:35:40_2000_886)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="foo.c"

#include "ruby.h"

VALUE mFoo;

static VALUE
_bar(VALUE self)
{
	printf("bar\n");
	return self;
}

void Init_foo(void)
{
	printf("hoge\n");
	mFoo  b_define_module("Foo");

	rb_define_module_function(mFoo, "bar", _bar, 0);
}

----Next_Part(Fri_Jan__7_23:35:40_2000_886)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="foo.rb"

require 'foo'
inclued Foo
Foo.bar

----Next_Part(Fri_Jan__7_23:35:40_2000_886)----