Build Haxe on Windows

This page explains how to build haxe from souce with 'ocaml'. Although the described procedures below still work, it is now recommended to use 'make'. Detailed instructions for using 'make' to build haxe can be found here.


To start with you should have Microsoft Visual Studio, TortoiseCVS, and Subversion command line installed. If you install the free Visual C++ 2005 Express Edition, you will also need to install the MASM (Microsoft Assembler) and Platform SDK (or use this older version if you're on Windows 2000). Note that Visual C++ 2008 Express Edition requires Service Pack 1 for MASM support, but then you do not need to install MASM separately.

Download and install the "Microsoft toolchain" version of Ocaml. You also need Flexlink installed.

Now, add C:\Program Files\CVSNT\;C:\Program Files\Flexdll to your path.

Ensure you have the aforementioned Save this file in the same directory as you would like to put all the other Haxe files, e.g. C:\haxe\

Download zlib from and extract the contents to C:\haxe\zlib123-dll. Copy (or rename) C:\haxe\zlib123-dll\lib\zdll.lib to zlib.lib

You will now want to open the Visual Studio command prompt. (See the extra Visual Studio Tools under the main Visual Studio menu ).

In this command prompt, enter these commands:

cd C:\haxe\
SET LIB=%LIB%;"C:\haxe\zlib123-dll\lib"
SET INCLUDE=%INCLUDE%;"C:\haxe\zlib123-dll\include"

and now run the install:


If you finish with:

copy zlib123-dll\zlib1.dll bin

you should then have a working haxe.exe in C:\haxe\bin\.

To make it work, you have to make sure the std directory is next to the haxe.exe file. So, copy c:\haxe\haxe\std and all contents to c:\haxe\bin\std.
Finally, you can use the haxesetup.exe file bundled with a binary release to set up the environment correctly: Copy haxesetup.exe to c:\haxe\bin\haxesetup.exe and run it.



As with everything, please read all instructions before starting.

- Install Cygwin if you have not done so already.
When installing or upgrading, don't forget to check for autoconf, automake, binutils, gcc and ocaml.

svn checkout haxe-read-only
cd into the directory then
If you want to set a location for your haxe files to be installed to, edit Makefile and change the value of EXPORT to your desired directory and call
make export
At this point, if cygwin is not in your PATH, calling haxe from windows command line will throw errors for cyggcc_s-1.dll, cygwin1.dll, or cygz.dll. DO NOT move these files, the solution is to add
to your PATH environment variable.


Before starting, please read the notes below.


- The installations of MinGW and MSYS are standard and can be used for other projects.
- You should install the packages in directories like c:/mingw or c:/my_path_without_space/mingw.
- You might not want to use the version 4.3.1 of gcc (latest available for MinGW) as some people reported it as sometimes unstable... See Links for other versions.
- GNUWin32 packages are optional but usefull, wget for example to download the
- If you encounter problems with make in other projects, download and extract in your msys directory the lastest MSYS Make.

MinGW (Standard Install)

- Download MinGW
- Donwload MinGW Binutils
- Download MinGW Runtime
- Download MinGW Win32Api
- Download MinGW Utils
- Download MinGW GDB
- Download MinGW Make

- Download MinGW GCC 4.3.1 - core
- Download MinGW GCC 4.3.1 - g++

- Install MinGW and then simply extract all the other archives in your mingw directory.

MSYS (Standard Install)

- Download MSYS
- Download MSYS DTK
- Download MSYS Bash

- Install MSYS then MSYS-DTK and extract the bash in your msys directory.


- Download and install MinGW-OCaml


- Donwload MSYS zlib

Note: You can also download the latest zlib tarball and compile it under MinGW.

GNUWIN32 (Optional)

- Download and install GNUWin32 Wget
- Download other GNUWin32 packages your're interested in. See Links.

Configure MSYS

- Create ocaml and gnuwin32 directories in path/to/msys/.
- Edit path/to/msys/etc/fstab, add 2 lines at the end: X:/my/path/to/gnuwin32 /gnuwin32 and X:/my/path/to/ocaml /ocaml. See the existing line in this file for correct syntax.
- Create a .profile file in path/to/msys/home/your_name/ and add this line to the file:

export PATH=".:/usr/local/bin:/mingw/bin:/bin:/gnuwin32/bin:/ocaml/bin:$PATH"

- Create a haxe directory in path/to/msys/home/your_name/
- Create a zlib directory in path/to/msys/home/your_name/haxe/
- Extract MSYS zlib archive somewhere and copy include/zconf.h, include/zlib.h and lib/zlib.a to your haxe/zlib/ directory.

Compile Haxe

- Download the Haxe
- Edit it, see below [1] the modifications to make in this file.

- Start MSYS terminal and type

cd haxe

- Start the installation by typing
OCAMLLIB="/ocaml/lib/" ocaml

- That will download the Haxe sources and start to compile Haxe.
- You'll get an error: "Installing extLib.lib", "Aborted", "Error in etc."

- Edit the file path/to/msys/home/your_name/haxe/ocaml/extlib-dev/ See below [2].
- Restart the installation

OCAMLLIB="/ocaml/lib/" ocaml

- Everything should be fine now and once finished you'll find haxe.exe in bin/

- You're done.

Note: Don't forget to copy the haxe/std directory along with your haxe.exe

File Modifications

Note: they are reversible in both files, you just have to comment the line: let os_type = "MinGW"

Haxe Modifications:

line 32 : after (* let os_type = "Cygwin" *) add a new line: let os_type = "MinGW".
line 36 : replace "Win32" | "Cygwin" by "Win32" | "Cygwin" | "MinGW"
line 40 : add a new line: | "MinGW" -> "../zlib/"
line 45 : add a new line: | "MinGW" -> zlib_path ^ "libz.a"

extlib-dev Modifications:

line 52 : add 2 lines : let os_type = Sys.os_type and let os_type = "MinGW"
line 55 : replace Sys.os_type by os_type
line 56 : replace | "Unix" | "Cygwin" | "MacOS" by | "Unix" | "Cygwin" | "MacOS" | "MinGW"

Some ocaml problems migth occur

> you might have problems with libws2_32.a,
line 164 : replace if native then command ("ocamlopt
by if native then command ("ocamlopt -cclib \"-nocygpath -L path\to\mingwlib"
its basically telling the linker where to find C libs

> flexdll might be needed, you can find its binaries on the web.


- MinGW/MSYS Home Page
- Latest MinGW/MSYS packages
- Latest GCC for MinGW
- GNUWin32 packages

version #15208, modified 2012-07-28 16:20:33 by jan_flanders