Ruby require wrong argument type error

353 views Asked by At

I implement ruby extension in c++. it compiled. but when i require module which i implement in my ruby test, it show an error. i create similar small module and require it same way in ruby code. it work fine. i can't figure out what is the problem. please help me. thank you.

here is my code.

extconf.rb

     require 'mkmf';
     have_library( 'stdc++' );
     $CFLAGS << " -Wall";
     create_makefile( 'Graph' ); 

Rgraph.cpp

     /*relevant methods here*/
     extern "C" void Init_Graph(){
     /* create Graph module */
     Mgraph = rb_define_module("Graph");
     Rgraphbase = rb_define_class_under(Mgraph,"GraphBase",rb_cObject);
     rb_define_alloc_func(Rgraphbase,alloc_ldgb_ob);
     /* some ruby define methods */

test.rb

     require 'rubygems'
     require '/home/kelum/workspace/myextension/ext/Rlgem/graph/Graph' 
     include Graph
     puts "some test methods";  

i compiled it using these commands

     ruby extconf.rb
     make
     ruby test.rb

but when i execute ruby test.rb it show an error.

    /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': wrong argument type false (expected Class) (TypeError)
  from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  from test.rb:2:in `<main>'

please help me to fix this. thanks.

0

There are 0 answers