12.13.1 Getting started with Haxe/HashLink

Prerequisites

In order to run Hashlink bytecode and compile Hashlink/C, the Hashlink binaries must be installed. These binaries can be obtained either by downloading a release version or by building them from source.

Additionally, for compiling Haxe to Hashlink/C, the hashlink haxelib package must also be installed. It is recommended to install it directly from source, via the command:

haxelib git hashlink https://github.com/HaxeFoundation/hashlink.git master other/haxelib/
Sample

To get started with Haxe/HashLink, create a new folder and save this class as Main.hx.

/**
    Multi-line comments for documentation.
**/
class Main {
    static public function main():Void {
        // Single line comment
        trace("Hello World");
    }
}

To compile, either run the following from the command line:

haxe --hl hello.hl --main Main

Another possibility is to create and run (double-click) a file called compile.hxml. In this example the hxml file should be in the same directory as the example class.

--hl hello.hl
--main Main

The compiler outputs a file called hello.hl in the current folder, which can be executed with hl hello.hl from the command line.

More information