Forum: Ruby calling Ruby from C/C++

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mr_Tibs (Guest)
on 2009-01-08 20:05
(Received via mailing list)
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
Mohit S. (Guest)
on 2009-01-08 20:10
(Received via mailing list)
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.
Mr_Tibs (Guest)
on 2009-01-08 20:25
(Received via mailing list)
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.
Mohit S. (Guest)
on 2009-01-08 20:48
(Received via mailing list)
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.
Mr_Tibs (Guest)
on 2009-01-08 21:05
(Received via mailing list)
Coo. Thanks. I don't know how I missed that.
Mohit S. (Guest)
on 2009-01-08 21:21
(Received via mailing list)
Mr_Tibs wrote:
> Coo. Thanks. I don't know how I missed that.
>
It's easy to miss it :)

Hope this helps.

Cheers,
Mohit.
1/9/2009 | 3:19 AM.
This topic is locked and can not be replied to.