Learn how to build a native executable of your app
Ruby programs are simply text files that can be run by a Ruby interpreter, like MRI / CRuby. Did you know you can also compile your programs to native code using MRuby.
First, you’ll need to install MRuby:
brew install mruby brew tap simple2d/tap brew install simple2d
# Ubuntu, Debian, and Mint sudo apt install mruby libmruby-dev # Other Linux distributions, search your package manager
With MRuby installed, using the “Hello Triangle” script you wrote above, run the following to build a native and web-based version of the app:
ruby2d build app.rb
build/ directory was created containing an executable named either
app on Unix-like systems, or
app.exe on Windows.
The executable is a compiled, native version of your app. It can run on any system, similar to the one you built it on, without the need for the full Ruby interpreter to be present. Let’s try running the native app on the command line:
# Enter the `build/` directory cd build # Run on Unix-like systems ./app # Run on Windows app.exe
Continue to the next topic ▸