Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.84 KB

File metadata and controls

54 lines (39 loc) · 1.84 KB
title Native
subtitle Learn how to build a native executable of your app
next_topic console
layout learn

{% include warning.html icon="⚠️" message="Warning: This is experimental! You can try it out, but it may not work well." %}

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:

  • On macOS, we recommend using Homebrew to install MRuby and Simple 2D:
brew install mruby
brew tap simple2d/tap
brew install simple2d
  • On Linux, use your package manager:

    # Ubuntu, Debian, and Mint
    sudo apt install mruby libmruby-dev
    
    # Other Linux distributions, search your package manager

    If your distribution, doesn't have an MRuby package, compile and install from source instead. Next, install Simple 2D using these instructions.

  • On Windows, we don't yet have instructions, but we're working on it!

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

Notice a 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 »](/learn/{{ page.next_topic }})