HashLink is a virtual machine for the Haxe programming language. By targeting HashLink you are also able to generate Native C code for your project.
Heaps is able to support both SDL and DirectX. In order to specify which you'd like to use, you simple need to include the appropriate library when compiling your project.
For DirectX (optionally DirectX 12)
-lib hldx
#-D dx12
For SDL
-lib hlsdl
To compile for hl/jit, use the following example.
# class paths
-cp src
# entry point
-main Main
# libraries
-lib heaps
-lib format
-lib hldx
#-D dx12
#-lib hlsdl
# output
-hl bin/game.hl
And run with:
hl bin/game.hl
Alternatively, you can compile for hl/c, and then compile C files with a C compiler.
# class paths (same as hl/jit)
-cp src
# entry point (same as hl/jit)
-main Main
# libraries (same as hl/jit)
-lib heaps
-lib format
-lib hldx
#-D dx12
#-lib hlsdl
# output
-hl bin/hlcout/game.c
If you're using GCC, you can build with:
gcc -O3 -o myapp -std=c11 -I out out/main.c -lhl -lheaps.hdll -lui.hdll -lfmt.hdll [-L/path/to/required/hdll]
For template, see also Hashlink#706.
If you're using Visual Studio, add the following line in your hxml file:
# use a Visual Studio template
-D hlgen.makefile=vs2019
-D hlgen.makefilepath=bin
#-D hlgen.makefile.jumbo=false
You'll need to set an environment variable HASHLINK
point to your hashlink installation folder.
You can then compile using bin/game.sln
, or with this sample makefile:
PLATFORM=x64
MS_BUILD?="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe"
#MS_BUILD?="C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/MSBuild.exe"
CONFIG?=Release
all:
$(MS_BUILD) game.sln -t:game -nologo -verbosity:minimal -property:Configuration=$(CONFIG) -property:Platform=$(PLATFORM)