From: Joel VanderWerf Date: 2011-04-30T07:32:32+09:00 Subject: Re: Building extention with multiple classes On 04/29/2011 02:39 PM, Richard Shinn wrote: > Hello, > > I have been successful at building a ruby extension that contains one > new class and now I would like to build multiple classes. I am wondering > what is the best way to do this. Take a look at the ext/ dir in ruby's source. For example, in socket.c: void Init_socket() { rb_eSocket = rb_define_class("SocketError", rb_eStandardError); rb_cBasicSocket = rb_define_class("BasicSocket", rb_cIO); This snippet defines two classes. Farther down you'll see the rb_define_method() calls to associate the C functions that implement methods, and also the C functions themselves. These functions can just as well be defined in separate .c files in the same dir. They will get found by extconf.rb (in the create_makefile call, IIRC).