Skip to content

Instantly share code, notes, and snippets.

@cowwabanga
Created February 21, 2024 08:18
Show Gist options
  • Save cowwabanga/81849e59e9f83df0d0e05aa20565bffb to your computer and use it in GitHub Desktop.
Save cowwabanga/81849e59e9f83df0d0e05aa20565bffb to your computer and use it in GitHub Desktop.
How to install Haxe on Linux

Getting started with Haxe

Note

Source is no longer available.
Important to say, some things can be outdated.

This doc is a guide to installing and setting up the latest version of Haxe onto Debian GNU/Linux (the “Testing” distribution).

Install

We’ll install the newest Haxe binary release into ~/opt, and create a couple of symlinks in ~/bin.

Important

If you don’t already have a ~/bin directory, you’ll need to create one, and then make sure it’s on your PATH.

Go to the Haxe Download page and download the Linux 64-bit binaries. Unpack and install like so:

mv path/to/haxe-4.n.m-linux64.tar.gz ~/opt
cd ~/opt
tar xzf haxe-4.n.m-linux64.tar.gz
# Note, that archive unpacks into a directly named like
# haxe_YYYYMMDDhhmmss_xxxxxxx. Rename it to something
# more human-readable:
mv haxe_201xxxxxxxxxxx_xxxxxxx haxe-4.n.m
ln -s haxe-4.n.m haxe
cd ~/bin
ln -s ~/opt/haxe/haxe .
ln -s ~/opt/haxe/haxelib .

Then, so haxe can find its std library, into your ~/.bashrc add:

export HAXE_STD_PATH="$HOME/opt/haxe/std"

Finally, set up haxelib (the library installer tool):

haxelib setup

When prompted for the directory within which haxelib will store installed library files, rather than the default, I specify ~/haxelib. (This directory name will be stored in the ~/.haxelib file.)

Important

If you don’t already have it installed, you’ll need to apt install neko, as haxelib requires it.

Upgrading

To upgrade to a newer release candidate:

  1. As described above: download and unpack the newer Haxe release into ~/opt, and rename the resulting directory to a more human-readable name (like “haxe-4.n.m”).
  2. Still in ~/opt, rm the “haxe” symlink and make a new one pointing to the newly unpacked & renamed haxe-4.n.m directory.

Switching Between Installed Versions

You can at any time easily switch between versions of Haxe in your ~/opt; just rm that symlink named “haxe” and make a new one pointing to a different “haxe-4.n.m” directory.

Check Installation

$ which haxe haxelib
/home/YOU/bin/haxe
/home/YOU/bin/haxelib

$ haxe --version
4.n.m

$ haxelib version
4.n.m  # possibly different from what `haxe` reports

Try it out

Try Haxe out on some code. cd path/to/my-proj. Create a src/Main.hx file containing:

And an interp.hxml build file containing:

class Main {
    public static function main() {
        trace("Hello, World!");
    }
}

And an interp.hxml build file containing:

-p src
-m Main
--interp

Run your program (this is using Haxe’s built-in interpreter):

haxe interp.hxml

getting this output:

Main.hx:3: Hello, World!

Woo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment