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.
On Dec 23, 8:28pm, Chananya F. [email protected] 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?
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.
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:
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
’
There’s no way to put a code/source tag of some sort?
[edit]
By writing “include MyTest” it actually allows me to use test1, why
can’t I use it directly?
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? GCC? Something?
I’ve attached sample files.
(I noticed that “t” in the Init, it’s a typo that doesn’t matter)
On Fri, Dec 24, 2010 at 12:23 PM, Chananya F.
[email protected] 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:
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