Making a C extension

L

Luis Lavena

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?

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.
 
C

Chananya Freiman

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>'
 
A

Ammar Ali

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:

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top