# Help to create a Ruby extension in C

**URL:** <https://www.ruby-forum.com/t/help-to-create-a-ruby-extension-in-c/165662>\
**Category:** Ruby\
**Created:** [April 16, 2009, 6:49am UTC](https://www.ruby-forum.com/t/help-to-create-a-ruby-extension-in-c/165662 "2009-04-16T06:49:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [April 16, 2009, 6:49am UTC](https://www.ruby-forum.com/t/help-to-create-a-ruby-extension-in-c/165662/1 "2009-04-16T06:49:44Z")

</div>

hi…  
i just followed the peter cooper’s tutorial on How to create a Ruby  
extension in C in under 5 minutes in the [rubyinside.com](http://rubyinside.com).  
folowng the tutorial i create extconf.rb and MyTest.c .  
i installed the cygwin.

in that command prompt i given command =\>$ ruby extconf.rb

after giving the command it created the makefile in to my folder.

after that i given command =\> $ make

it creates MyTest.o file and mytest(this file type is Apache Loadable  
Module)

and no errors…

it has not created the .so file into my folder…

In irb when i give require ‘mytest’

the irb doesnot display anything…

what is the problem…and what i m doing wrong…

Kindly Help Me out…

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [April 16, 2009, 9:12am UTC](https://www.ruby-forum.com/t/help-to-create-a-ruby-extension-in-c/165662/2 "2009-04-16T09:12:05Z")

</div>

Newb N. wrote:

> it creates MyTest.o file and mytest(this file type is Apache Loadable  
> Module)

Possibly would be a DLL for Windows?

> In irb when i give require ‘mytest’
> 
> the irb doesnot display anything…

Can you paste _exactly_ what you see? If it returns “true” then the  
extension was loaded correctly. Or did it crash IRB, i.e. you didn’t  
even get a prompt back?

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [April 16, 2009, 9:22am UTC](https://www.ruby-forum.com/t/help-to-create-a-ruby-extension-in-c/165662/3 "2009-04-16T09:22:49Z")

</div>

Brian C. wrote:

> Newb N. wrote:
> 
> > it creates MyTest.o file and mytest(this file type is Apache Loadable  
> > Module)
> 
> Possibly would be a DLL for Windows?
> 
> > In irb when i give require ‘mytest’
> > 
> > the irb doesnot display anything…
> 
> Can you paste _exactly_ what you see? If it returns “true” then the  
> extension was loaded correctly. Or did it crash IRB, i.e. you didn’t  
> even get a prompt back?

thank you…it actaully created .so file…  
but when i give require command it gives me true…  
but want to know wat it does when i give require ‘mytest’ command…  
and when i give command like require ‘MyTest’ command it shows me  
error…

what is the reason

Thanks

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [April 16, 2009, 10:37am UTC](https://www.ruby-forum.com/t/help-to-create-a-ruby-extension-in-c/165662/4 "2009-04-16T10:37:06Z")

</div>

On Apr 16, 2009, at 00:22 , Newb N. wrote:

> thank you…it actaully created .so file…  
> but when i give require command it gives me true…  
> but want to know wat it does when i give require ‘mytest’ command…  
> and when i give command like require ‘MyTest’ command it shows me  
> error…  
> what is the reason

the file is named “mytest.so” and you’re probably on a case sensitive  
file system. I’m guessing you don’t have a file named MyTest.so  
(or .rb).

look at your doco for Kernel#require to see what it does. You can use  
`ri` for that or look it up on rubydoc or somesuch.
