# Extending other languages with Ruby

**URL:** <https://www.ruby-forum.com/t/extending-other-languages-with-ruby/90350>\
**Category:** Ruby\
**Created:** [March 28, 2007, 2:15am UTC](https://www.ruby-forum.com/t/extending-other-languages-with-ruby/90350 "2007-03-28T02:15:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![djmook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@djmook](https://www.ruby-forum.com/u/djmook)\
**Post date:** [March 28, 2007, 2:15am UTC](https://www.ruby-forum.com/t/extending-other-languages-with-ruby/90350/1 "2007-03-28T02:15:37Z")

</div>

Hello,

I have recently been trying to figure out how to extend another language  
by using Ruby as a scripting language. I have found a bit of information  
on how to do this, but it is mostly just bland explanations and, seeing  
as I am a visual learner, I am having a lot of trouble figuring out how  
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.

Thanks!

---

<div class="post-metadata">

**Author:** ![djmook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@djmook](https://www.ruby-forum.com/u/djmook)\
**Post date:** [March 28, 2007, 2:19am UTC](https://www.ruby-forum.com/t/extending-other-languages-with-ruby/90350/2 "2007-03-28T02:19:37Z")

</div>

On Mar 27, 2007, at 7:15 PM, Mark C. 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://  
[R. Mark Volkmann | Object Computing, Inc.](http://www.ociweb.com/mark).

---

<div class="post-metadata">

**Author:** ![djmook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@djmook](https://www.ruby-forum.com/u/djmook)\
**Post date:** [March 28, 2007, 4:46am UTC](https://www.ruby-forum.com/t/extending-other-languages-with-ruby/90350/3 "2007-03-28T04:46:40Z")

</div>

Mark V. wrote:

> On Mar 27, 2007, at 7:15 PM, Mark C. 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](http://www.ociweb.com/mark).

Those are very awesome, and I appreciate that you shared them with me.  
They’ve definitely helped me quite a bit, but now all I am left  
wondering is if/how I can do the same using C# (Mono, preferably). Any  
more information would be extremely useful!

Thanks!

---

<div class="post-metadata">

**Author:** ![djmook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@djmook](https://www.ruby-forum.com/u/djmook)\
**Post date:** [March 29, 2007, 1:43am UTC](https://www.ruby-forum.com/t/extending-other-languages-with-ruby/90350/4 "2007-03-29T01:43:48Z")

</div>

Mark V. wrote:

> On Mar 27, 2007, at 7:15 PM, Mark C. 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](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 \<ruby.h\>

main() {  
ruby\_init();  
ruby\_script(“embedded”);  
rb\_load\_file(“start.rb”);  
while (1) {  
ruby\_run();  
}  
}

Thanks!

---

<div class="post-metadata">

**Author:** ![djmook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@djmook](https://www.ruby-forum.com/u/djmook)\
**Post date:** [March 29, 2007, 2:15am UTC](https://www.ruby-forum.com/t/extending-other-languages-with-ruby/90350/5 "2007-03-29T02:15:53Z")

</div>

On 3/27/07, Mark C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Mark V. wrote:
> 
> > On Mar 27, 2007, at 7:15 PM, Mark C. wrote:  
> > 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](http://www.ociweb.com/mark).
> 
> Those are very awesome, and I appreciate that you shared them with me.  
> They’ve definitely helped me quite a bit, but now all I am left  
> wondering is if/how I can do the same using C# (Mono, preferably). Any  
> more information would be extremely useful!

RubyCLR ([http://www.rubyclr.com/](http://www.rubyclr.com/))  
IronRuby ([http://www.wilcob.com/Wilco/IronRuby.aspx](http://www.wilcob.com/Wilco/IronRuby.aspx))  
[Ruby.NET](http://Ruby.NET) ([http://plas.fit.qut.edu.au/Ruby.NET/](http://plas.fit.qut.edu.au/Ruby.NET/))  
Ruby/Mono ([http://raa.ruby-lang.org/project/ruby-mono/](http://raa.ruby-lang.org/project/ruby-mono/))

---

<div class="post-metadata">

**Author:** ![djmook](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d6d6ee/32.png) [@djmook](https://www.ruby-forum.com/u/djmook)\
**Post date:** [March 29, 2007, 1:59am UTC](https://www.ruby-forum.com/t/extending-other-languages-with-ruby/90350/6 "2007-03-29T01:59:53Z")

</div>

On Mar 28, 2007, at 6:43 PM, Mark C. wrote:

> > Ruby (JRuby) and one on extending C/C++ with Ruby. Both are at  
> > \_ruby\_init  
> > 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
