# Build Haxe on Windows

This page explains how to build haxe from souce with 'ocaml install.ml'. 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.

# VisualC++

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.

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

Download zlib from http://www.zlib.net/zlib123-dll.zip 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:

ocaml install.ml

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.

Enjoy!

# Cygwin

- 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 http://haxe.googlecode.com/svn/trunk/ haxe-read-only
cd into the directory then
run
make
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
c:\path\to\cygwin\bin

# Mingw

### Notes

- 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 install.ml.
- If you encounter problems with make in other projects, download and extract in your msys directory the lastest MSYS Make.

### MinGW (Standard Install)

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

### MSYS (Standard Install)

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

### libZ

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

### 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

- 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 install.ml

- 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/install.ml. See below [2].
- Restart the installation

OCAMLLIB="/ocaml/lib/" ocaml install.ml

- 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 install.ml 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 install.ml 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. http://alain.frisch.fr/flexdll/