From: Zeng Ke Date: 2006-03-23T12:18:03+09:00 Subject: Re: C extensions question You'd better make the Makefile using extconf.rb, in which you can specify the library path and include path, as is told in the rubybook. Jared Richardson wrote: >Hi all, > >I haven't done any "real" work in C in nearly 10 years and I'm still >learning Ruby, so it's quite possible that I'm just doing something dumb, >but I'm stuck here. I'm trying to call Ingres database code from Ruby, so >I'm writing some C extensions. > >I have Ruby calling into C code. Very easy and very nice. > >I have Ingres sample code (which is C) compiling and running fine. > >However, when I try to invoke Ingres code from any of my C code and run it >(from Ruby), I get a seg fault. > >It feels like Ruby can't see the Ingres libraries but the code samples don't >seem to having any problems. I suspect I'm missing something simple... > >Do you need to do any special wrapping or declaring of code that isn't >touched from within your Ruby? I've been through the Pickaxe book and >several online samples/tutorials and I don't see that it's needed... but >then again, my code isn't running. :) > >Here's my code as it is now... any hints or clues? > >#include "ruby.h" ># include ># include > >static VALUE cIngres; > >static VALUE ii_exec(VALUE self) { > printf("\n\nExec was run from within the Ruby code \n\n"); > IIAPI_INITPARM initParm; > printf("one\n"); > IIapi_initialize( &initParm ); > printf("two\n"); > return Qnil; >} > >void Init_Ingres() { > cIngres = rb_define_class("Ingres", rb_cObject); > rb_define_method(cIngres, "exec", ii_exec, 0); >} > > >Thanks! > >Jared >http://jaredrichardson.net > > > > > >---- X-Spam-Report ---- > >No, hits=-1.4 required=5.0 > > 0.1 RCVD_BY_IP Received by mail server with no name > -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% > [score: 0.0000] > 1.1 PRIORITY_NO_NAME Message has priority, but no X-Mailer/User-Agent > > > >