How to use Ruby interpreter as Windows DLL library?

  • Thread starter Stanislav Sidristij
  • Start date
S

Stanislav Sidristij

I have an idea (program, that uses Ruby interpreter). And I dont know
how to use Ruby interpreter in my program. I looking for manuals (but I
dont know English very well and I cannot find information about this) or
ideas how can I do this. If you can, please, write: is it possible to
use Ruby as DLL in my program? How can I call interpreter functions and
how can I set (and get) variables values. And is correct to use Ruby as
DLL in commercial program?
Russian programmer :)
 
D

Dean Wampler

I don't know if this helps, but RubyScript2Exe

http://www.erikveen.dds.nl/rubyscript2exe/index.html

is a great tool for converting your ruby scripts into a standalone
windows executable, including an embedded Ruby interpreter and all the
required libraries. I'm using it for running Ruby as part of an
application installer where I don't expect the user to have Ruby
installed already.

The only drawback I've seen is that the exe's tend to be large, even
for small scripts (~1 MB). Not an issue for me, however.

dean
 
B

Bill Kelly

Hi,

From: "Stanislav Sidristij said:
I have an idea (program, that uses Ruby interpreter). And I dont know
how to use Ruby interpreter in my program. I looking for manuals (but I
dont know English very well and I cannot find information about this) or
ideas how can I do this. If you can, please, write: is it possible to
use Ruby as DLL in my program? How can I call interpreter functions and
how can I set (and get) variables values. And is correct to use Ruby as
DLL in commercial program?
Russian programmer :)

Here's some very basic code to load and run a ruby script from C/C++

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#ifdef _WIN32
// ruby win32 init
int argc = 0;
char **argv = 0;
NtInitialize(&argc, &argv);
#endif

ruby_init();
ruby_script("embedded");

// TODO - rb_str_new2 could call ruby_raise if out of memory, so we should
// catch that possible exception here
//
int status;
rb_load_protect(rb_str_new2("ruby-program.rb"), 0, &status);
if (status == 0) {
int state = ruby_exec();
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

See the README.EXT file in your Ruby installation for more info.

See also: http://metaeditor.sourceforge.net/embed/ for much more sophisticated
examples...


Hope this helps,

Regards,

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,291
Messages
2,571,483
Members
48,148
Latest member
LXB-Studio

Latest Threads

Top