How to use Ruby interpreter as Windows DLL library?


#1

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 :slight_smile:


#2

Oh… Calling from C/C++… Windows XP platform.


#3

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

On 2/4/06, Stanislav S. removed_email_address@domain.invalid wrote:

Oh… Calling from C/C++… Windows XP platform.


Posted via http://www.ruby-forum.com/.


Dean W.
http://www.aspectprogramming.com
http://www.newaspects.com
http://www.contract4j.org


#4

Bill K. wrote:

Hi,


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

Thanks a lot for your way!!! Thanks! Thanks! Thanks! =)


#5

Hi,

From: “Stanislav S.” removed_email_address@domain.invalid

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 :slight_smile:

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