pickaxe ruby extension example.

A

Aaron Smith

Strange, I had the extension working a while ago from the pickaxe book.
Now when I run the extconf.rb and make I get some errors.. any ideas?

EX:
Code:
#include "ruby.h"
static int id_push;
static VALUE t_init(VALUE self)
{
VALUE arr;
arr = rb_ary_new();
rb_iv_set(self, "@arr", arr);
return self;
}

static VALUE t_add(VALUE self, VALUE obj)
{
VALUE arr;
arr = rb_iv_get(self, "@arr");
rb_funcall(arr, id_push, 1, obj);
return arr;
}

VALUE cTest;
void Init_my_test()
{
cTest = rb_define_class("MyTest",rb_cObject);
rb_define_method(cTest, "initialize", t_init, 0);
rb_define_method(cTest, "add", t_add, 1);
id_push = rb_intern("push");
}
gcc -I. -I/usr/local/lib/ruby/1.8/i686-darwin8.8.2
-I/usr/local/lib/ruby/1.8/i686-darwin8.8.2 -I. -fno-common -g -O2
-fno-common -fno-common -pipe -fno-common -c my_test.c
cc -dynamic -bundle -undefined suppress -flat_namespace
-L"/usr/local/lib" -o my_test.bundle my_test.o -lruby -lpthread -ldl
-lobjc
/usr/bin/ld: warning multiple definitions of symbol _setregid
/usr/local/lib/libruby.dylib(process.o) definition of _setregid
/usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libpthread.dylib(setregid.So)
definition of _setregid
/usr/bin/ld: warning multiple definitions of symbol _setreuid
/usr/local/lib/libruby.dylib(process.o) definition of _setreuid
/usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libpthread.dylib(setreuid.So)
definition of _setreuid
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top