Making a C extension

I can't seem to get even the simplest C extension taken from
http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html
to work.

The interpreter acknowledges that MyTest exists and knows it's a module,
but it doesn't recognize the method(s) I define.

You guys have any idea why this happens?

Thanks.

···

--
Posted via http://www.ruby-forum.com/.

Please include full output and complete error messages you're getting.
Your assumption of the problem is not helping us figure out what is
going on in your environment.

Also, include the more information as possible about your system,
version of Ruby, location of the files, etc.

The more information, the better we can help you.

···

On Dec 23, 8:28 pm, Chananya Freiman <thebluedrag...@gmail.com> wrote:

I can't seem to get even the simplest C extension taken fromhttp://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-unde...
to work.

The interpreter acknowledges that MyTest exists and knows it's a module,
but it doesn't recognize the method(s) I define.

You guys have any idea why this happens?

--
Luis Lavena

Windows 7, Ruby 1.9.2.

The code is just in an arbitrary folder, so I have to include it with
"require './file'" because otherwise Ruby can't find it.

The error just says there's no such method in my module, here's a
snapshot of irb:

[code]
irb(main):001:0> require './mytest'
=> true
irb(main):002:0> MyTest
=> MyTest
irb(main):003:0> MyTest.class
=> Module
irb(main):004:0> MyTest.test1
NoMethodError: undefined method `test1' for MyTest:Module
        from (irb):4
        from C:/Ruby192/bin/irb:12:in `<main>'
[/code]

···

--
Posted via http://www.ruby-forum.com/.

Ok....not sure if this is related to Ruby exactly, but I found something
extraordinarily odd!

If I use Ruby to generate a Makefile for me and use "make", it
completely ignores every "near" and "far" in the C file.
They simply don't exist as far as GCC cares for...

Is this some bug in make?

I've attached sample files.

Attachments:
http://www.ruby-forum.com/attachment/5618/extconf.rb
http://www.ruby-forum.com/attachment/5619/Test.c

···

--
Posted via http://www.ruby-forum.com/.

That tutorial is very old and out of date for 1.9.2. If you want to
call the method as you did in the above irb session, then you should
define the method with rb_define_module_function instead of
rb_define_method.

Please read the README.EXT which comes with the ruby source for a good
overview of latest API.

HTH,
Ammar

···

On Fri, Dec 24, 2010 at 12:23 PM, Chananya Freiman <thebluedragont@gmail.com> wrote:

Windows 7, Ruby 1.9.2.

The code is just in an arbitrary folder, so I have to include it with
"require './file'" because otherwise Ruby can't find it.

The error just says there's no such method in my module, here's a
snapshot of irb: