Calling Ruby from C/C++


#1

Hi,

Is there a way to execute Ruby code from C/C++? I know it is possible
to call Tcl code from C/C++; the Tcl library provides a
Tcl_CreateInterp() function which creates an in-process interpreter
running the Tcl code. Does Ruby provide something similar?

I cannot use any system() or forking functions.

Thanks,
Tiberiu


#2

Mr_Tibs wrote:

Hi,

Is there a way to execute Ruby code from C/C++? I know it is possible
to call Tcl code from C/C++; the Tcl library provides a
Tcl_CreateInterp() function which creates an in-process interpreter
running the Tcl code. Does Ruby provide something similar?

Yes it does. Search up “ruby c c++” (without quotes) in Google.

Also, see - http://whytheluckystiff.net/ruby/pickaxe/html/ext_ruby.html

Cheers,
Mohit.
1/9/2009 | 2:09 AM.


#3

It seems that everything I find on the web is about calling C from
Ruby (which is C extensions). I need to do call Ruby from C.


#4

Mr_Tibs wrote:

It seems that everything I find on the web is about calling C from
Ruby (which is C extensions). I need to do call Ruby from C.

Perhaps, you misunderstood the pages. I asked for you to search “ruby c
c++” - Please see the following:

[1] From the first hit:
http://metaeditor.sourceforge.net/embed/
In this document I will descripe how to embed the ruby interpreter into
c++ [WhyEmbedRuby?, EmbedRuby] and provide you with a skeleton you
easily can build upon.

[2] The URL I sent:
http://whytheluckystiff.net/ruby/pickaxe/html/ext_ruby.html
Please scroll down the page till you find ‘Embedding a Ruby Interpreter’

and so on.

You could also search up ‘embed ruby c c++’

Cheers,
Mohit.
1/9/2009 | 2:45 AM.


#5

Mr_Tibs wrote:

Coo. Thanks. I don’t know how I missed that.

It’s easy to miss it :slight_smile:

Hope this helps.

Cheers,
Mohit.
1/9/2009 | 3:19 AM.


#6

Coo. Thanks. I don’t know how I missed that.