D
Daniel Berger
Hi,
How do you get at a static function from within a C extension? I tried
this snippet where I attempt to use flo_plus from numeric.c:
/* foo.c */
#include <ruby.h>
extern VALUE flo_plus(VALUE, VALUE);
static VALUE foo_test(VALUE x, VALUE y){
return flo_plus(x, y);
}
void Init_foo(){
VALUE cFoo = rb_define_class("Foo", rb_cObject);
rb_define_method(cFoo, "test", foo_test, 2);
}
# test.rb
$:unshift Dir.pwd
require 'foo'
f = Foo.new
f.test
This result is:
ruby: symbol lookup error:
/home/djberge/programming/ruby/extensions/foo.so: undefined symbol:
flo_plus
I tried linking explicitly against -lruby but that didn't help.
Regards,
Dan
How do you get at a static function from within a C extension? I tried
this snippet where I attempt to use flo_plus from numeric.c:
/* foo.c */
#include <ruby.h>
extern VALUE flo_plus(VALUE, VALUE);
static VALUE foo_test(VALUE x, VALUE y){
return flo_plus(x, y);
}
void Init_foo(){
VALUE cFoo = rb_define_class("Foo", rb_cObject);
rb_define_method(cFoo, "test", foo_test, 2);
}
# test.rb
$:unshift Dir.pwd
require 'foo'
f = Foo.new
f.test
This result is:
ruby: symbol lookup error:
/home/djberge/programming/ruby/extensions/foo.so: undefined symbol:
flo_plus
I tried linking explicitly against -lruby but that didn't help.
Regards,
Dan