12.12.2 HashLink/C Compilation

Haxe supports two modes of compilation for HashLink:

  • Compilation to HashLink bytecode. This mode has a very fast compilation time, so it is suitable for daily development.
  • Compilation to HashLink/C code, compiled with a native compiler to a regular executable. This mode results in the best performance, so it is suitable for final releases.
HashLink bytecode

Compiling to HashLink bytecode is achieved by specifying a .hl output in the -hl argument:

haxe -main Main -hl output.hl

This produces a single output.hl bytecode file, which can be executed with the HashLink JIT virtual machine with:

hl output.hl
HashLink/C code

Haxe code can also be compiled to HashLink/C code by specifying .c output in the -hl argument:

haxe -main Main -hl out/main.c

This produces files in the out directory, which can be compiled to a native executable with a C compiler such as gcc.

gcc -O3 -o hello -std=c++ -I out out/main.c -lhl [-L/path/to/required/hdll]

Note that during native compilation, the HL library must be linked. This library is available in binary distributions of HashLink, or can be obtained during compilation of HashLink from source.