From: Mark Volkmann Date: 2007-03-29T08:59:02+09:00 Subject: Re: Extending other languages with Ruby --Apple-Mail-40--749346583 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On Mar 28, 2007, at 6:43 PM, Mark Chandler wrote: > Mark Volkmann wrote: >> On Mar 27, 2007, at 7:15 PM, Mark Chandler wrote: >> >>> to correctly implement something like this without code examples or >>> something like that. Does anyone have a link to a better >>> explanation? It >>> would be nice if the extended language explanation were C++ or C# or >>> something like that. >> >> I have two slide presentations on this, one on extending Java with >> Ruby (JRuby) and one on extending C/C++ with Ruby. Both are at >> http:// >> www.ociweb.com/mark. > > I went ahead and decided to play around with embedding Ruby in a C > program, but now I am receiving this: > > lynxy:~/src/Ruby/Embed/Testing markchandler$ cc main.c > -I/usr/local/ruby/lib/ruby/1.8/i686-darwin8.9.1/ > /usr/bin/ld: Undefined symbols: > _rb_load_file > _ruby_init > _ruby_run > _ruby_script > collect2: ld returned 1 exit status > > The c code: > #include > > main() { > ruby_init(); > ruby_script("embedded"); > rb_load_file("start.rb"); > while (1) { > ruby_run(); > } > } Here are the commands that are run from Makefiles generated using mkmf for my example code. Maybe you'll see something in them that will help. "dealer" is the name of the C source file being compiled. gcc -I. -I/usr/local/lib/ruby/./i686-darwin8.9.1 -I/usr/local/lib/ ruby/./i686-darwin8.9.1 -I. -fno-common -g -O2 -pipe -fno-common -c dealer.c cc -dynamic -bundle -undefined suppress -flat_namespace -L"/usr/ local/lib" -o dealer.bundle dealer.o -ldl -lobjc --Apple-Mail-40--749346583--