From: Simon Strandgaard Date: 2004-01-03T09:46:43+09:00 Subject: Re: Embedding Ruby as a plugin (e.g. PhotoShop) On Thu, 01 Jan 2004 09:47:41 +0900, Glenn Lewis wrote: > I'm trying to embed Ruby as a plugin to a program called > Animation:Master (http://www.hash.com/). Everything compiles > and links without errors, and my plugin loads into A:M, and > my file requestor pops up for selecting which script I wish > to run through the Ruby interpreter. > > After this, though, I can't seem to get Ruby to run. > > If I try this: > > int myargc = 2; > char* myargv[] = { "ruby", "c:/src/hi.rb", 0 }; > ruby_init(); > ruby_options(myargc, myargv); > ruby_run(); // - crash Watch out about "ruby_run()".. see: http://www.rubygarden.org/ruby?RubyApi/RubyRun > the entire application crashes on the call to ruby_run. > If, however, I try this: > > ruby_init(); > ruby_script("embedded"); > rb_load_file("c:/src/hi.rb"); > ruby_run(); // - hangs > > the entire application just hangs... I have to kill it myself. > > Just to test out my sanity, I built a separate executable with > the above 2 snipits, and each of them worked fine as a stand-alone > program. > > I've tried linking to C:\ruby\lib\msvcrt-ruby18.lib > as well as C:\ruby\lib\msvcrt-ruby18-static.lib > and they behave the same. > > Can anyone think of what I might be doing wrong? > My e-mail address is: glenn at hometot periodcom > Thanks! > -- Glenn Lewis > > P.S. Notice how Paint Shop Pro has a python plugin for it? > It would be cool if someone wrote a Ruby plugin for it. Thanks. Great initiative. BTW: I recommend using SWIG as much as possible. I have written a tutorial on how to embed Ruby into C++, its located here: http://aeditor.rubyforge.org/ruby_cplusplus/index.html First you will need to download this skeleton project, though: http://raa.ruby-lang.org/list.rhtml?name=rubyembed It works on unix... no idea if it works on Windows (many has downloaded but nobody has yet submitted a windows-makefile, you are welcome). Just ask if you have any trouble. -- Simon Strandgaard