C embedding problem with 1.9

Hello.

I can’t manage to make the attached program to work with ruby 1.9.

When I run the program, it complain about unknown variable ‘a’. Here is
the exact error.

undefined local variable or method `a’ for main:Object

If I compile it using ruby 1.8, it works perfectly.

It occurs both on win32 and Ubuntu 9.10.
I tried ruby-1.9.1p243 on linux, and ruby-1.9.1-p376 on windows. I also
tried using a fresh build of the last version from the ruby CVS.

Any idea about the initialization error I certainly made ?

Thanks,
Thibaut

It seems that using a global variable by adding $ before the ‘a’
variable name solve the problem.

I am still stucked. The follwing code produce the error :
undefined method `synchronize’ for #Mutex:0x83b858c

int main(int argc, char ** argv){
int state;
ruby_sysinit(&argc, &argv);

RUBY_INIT_STACK
ruby_init();

ruby_init_loadpath();
ruby_script(“embed”);

rb_eval_string_protect("$mutex = Mutex.new", &state);
checkRubyError(state);

rb_eval_string_protect("$mutex.synchronize() { }", &state);
checkRubyError(state);

return 0;
}

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs