Building Haxe from source

Obtaining the source

The Haxe compiler sources are hosted on GitHub under the HaxeFoundation account. The Haxe repository has several submodules, so cloning it should be done with the --recursive flag like so:

git clone --recursive git://github.com/HaxeFoundation/haxe.git

Alternatively, source .zip archives or tarballs can be obtained from the GitHub Haxe release overview.

Building on OSX

The dependencies can be easily installed by Homebrew. In fact, if you only want to use the latest development branch of Haxe, without modifying the source, simply run:

brew install haxe --HEAD

Use brew reinstall haxe --HEAD to upgrade in the future.

If you want to start hacking the Haxe compiler, it is better to clone manually and use the Makefile:

  1. Install XQuartz (required by OCaml): brew install caskroom/cask/brew-cask && brew cask install xquartz
  2. Install OCaml: brew install ocaml
  3. Navigate to where the Haxe sources are and build Haxe using make:
make
make install

Building on Linux

  1. Install OCaml: http://ocaml.org/docs/install.html
  2. Navigate to where the Haxe sources are and build Haxe using make:
make
make install

Building on Windows (MSVC)

  1. Install a MSVC version of OCaml: http://caml.inria.fr/pub/distrib/
  2. Install any version of Visual C++ (Express): http://www.visualstudio.com/downloads/download-visual-studio-vs
  3. Install GNU make for Windows and GNU CoreUtils for Windows and add GnuWin32/bin to your PATH environment variable.
  4. Install Flexlink and add it to your PATH environment variable.

After this, open a Visual Studio command prompt or start a normal command prompt and run vcvarsall.bat in your Microsoft Visual Studio X/VC/ directory. The command cl should be available afterwards.

Navigate to where the Haxe sources are and build Haxe using:

make -f Makefile.win MSVC=1

For subsequent compilations it is usually enough to recompile the Haxe sources without its libraries:

make -f Makefile.win MSVC=1 haxe

Building on Windows (Cygwin)

  1. Install a Cygwin version of OCaml: http://protz.github.io/ocaml-installer/

    • To build Haxe you only need to choose OCaml and Cygwin in the install menu.
    • In the cygwin package selection window, select mingw64-i686-zlib in addition to pre-selected packages. This is required to build Haxe.
  2. Add the bin directory from Cygwin installation (e.g. C:\cygwin\bin) to your PATH environment variable. This will make unix commands, like make available.

  3. Add the usr\i686-w64-mingw32\sys-root\mingw\bin directory from the Cygwin installation (e.g. C:\cygwin\usr\i686-w64-mingw32\sys-root\mingw\bin) to your PATH environment variable. This makes required dynamically linked libraries, like zlib available for the compiled haxe.exe executable.

Navigate to where the Haxe sources are and build Haxe using:

make -f Makefile.win libs haxe haxelib

For subsequent compilations it is usually enough to recompile the Haxe sources without its libraries:

make -f Makefile.win haxe