[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to use Ruby interpreter as Windows DLL library?

Stanislav Sidristij

2/4/2006 11:54:00 AM

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

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


4 Answers

Stanislav Sidristij

2/4/2006 11:55:00 AM

0

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

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


Dean Wampler

2/4/2006 5:46:00 PM

0

I don't know if this helps, but RubyScript2Exe

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

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 Sidristij <sunexdev@mail.ru> wrote:
> Oh... Calling from C/C++... Windows XP platform.
>
> --
> Posted via http://www.ruby-....
>
>


--
Dean Wampler
http://www.aspectprogr...
http://www.newa...
http://www.cont...


Bill Kelly

2/4/2006 7:51:00 PM

0

Hi,

From: "Stanislav Sidristij" <sunexdev@mail.ru>
>
>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.... for much more sophisticated
examples...


Hope this helps,

Regards,

Bill




Stanislav Sidristij

2/4/2006 8:22:00 PM

0

Bill Kelly wrote:
> Hi,
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> See the README.EXT file in your Ruby installation for more info.
>
> See also: http://metaeditor.sourceforge.... for much more
> sophisticated
> examples...
>
>
> Hope this helps,
>
> Regards,
>
> Bill

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

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