[LRUG] Ruby 1.9 problem - mutex lib not loading properly

Alex MacCaw maccman at gmail.com
Thu Aug 13 09:58:44 PDT 2009


James,

Tried all that I'm afraid :(

Updated code is here: http://gist.github.com/167293

I'm following the bp-ruby project:
http://github.com/lloyd/bp-ruby/blob/master/src/RubyInterpreter.cpp#L70

Thanks,
Alex


> Hi Alex,
> There's a lot of inconclusive stuff on the net about embedding Ruby  
> 1.9, but
> one thing we've found we have to do (and this in a function that  
> doesn't
> return, i.e. main()[1]), is call the RUBY_INIT_STACK macro.
>
> In the system I'm working on, we also call ruby_sysinit(), but I  
> don't have
> the full code in front of me, so I can't tinker with it. Anyway,  
> here's our
> boot-up-ruby sequence:
>
> ruby_sysinit(&fake_argc, const_cast<char ***>(&fake_argv_star));
> RUBY_INIT_STACK;
> ruby_init();
> ruby_init_loadpath();
>
> Hope this helps. Let me know how you get on.
>
> James
>
> [1] http://www.ruby-forum.com/topic/149451
>
>
> 2009/8/11 Alex MacCaw <maccman at gmail.com>
>
>> I'm trying to evaluate Ruby (1.9) from C++.
>>
>> The code looks something like this:
>>
>>   rb_eval_string_protect("require 'thread'; m = Mutex.new;  
>> m.synchronize
>> {};", &error);
>>
>> The error I get is: undefined method `synchronize' for #<Mutex: 
>> 0x1f8cf4>
>>
>> It looks like the mutex class (which is written in C) isn't getting  
>> loaded
>> properly. Anybody got any ideas as to why?
>> The code works fine in Ruby 1.8
>>
>> http://pastie.org/579760
>>
>> --
>> http://www.leadthinking.com | http://socialmod.com
>>
>> _______________________________________________
>> Chat mailing list
>> Chat at lists.lrug.org
>> http://lists.lrug.org/listinfo.cgi/chat-lrug.org



More information about the Chat mailing list