Page 1 of 1

How to distribute Ruby Applications shows you how to create a .exe

#1 Rickster0  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 236
  • Joined: 08-July 08

Posted 07 October 2009 - 04:27 AM

Requirements:
Since ruby is an interpreted language, whenever you want to release your program you need to release the source code. Also your program users must install Ruby virtual machine before they can run your program. Is there a way to distribute ruby program as a standalone executable?

Erik Veenstra has created a tool called RubyScript2Exe which can convert a ruby program to an executable program. It does this by combining ruby interpreter code and your source code files into a single executable file.
First download the RubyScript2Exe. It is a ruby program ( abut 950kb in size). Create a simple ruby program called helloworld.rb and save it to the same location where you have RubyScript2Exe.rb stored.

puts "Hello World"  


From the command prompt, type the following,

ruby rubyscript2exe helloworld.rb


You will see the following output on console. Now you have a standalone executable program (helloworld.exe) which can be executed in any Windows machine! Combined with Win32API, you can create cool command line apps for Windows.

Posted Image

The only problem with this executable is that it contains the entire ruby VM and hence is large (helloworld.exe size is around 1.5MB). Also note that this is not really a ruby compiler. It doesn’t convert your ruby code to machine code. It only packages ruby virtual machine along with your ruby code. Hence the code is still interpreted.
RubyScript2Exe can also create executable files for Linux and Mac OS X.

If you need any other help, or you encounter any problems please PM me, or Post your problem here :D

Is This A Good Question/Topic? 0
  • +

Page 1 of 1