Search code examples
linuxcompilationexecutablecrystal-lang

Is it possible to compile a Crystal script so it can run on any Linux machine without the user having to download Crystal


There is a Crystal equivalent of OCRA (One-Click Ruby Application Builder) but it's only for Windows and I use Linux.


Solution

  • Crystal unlike Ruby is not interpreted or executed in a virtual machine. Crystal is compiled to native code ahead of execution using the LLVM. Application is started by the operating system not with interpreter.

    So yes, onсе compiled app can copy and run for any Linux machine with the same architecture. You may need to install system libs like libssl for use full featured stdlib but it is not critical.

    Crystal app is already OCRA (all of included shards will builded into one binary) if you specially have not used dynamic linking.

    What to read next:

    1. List of supported platforms
    2. Installation Crystal
    3. Using the Compiler for build app
    4. Crystal reference
    5. And API documentation