doc/advanced/compiler_guide [en]

All languages

Differences between version #4307 and #4601

1,372c1
< In order to compile Haxe, download {{install.ml}}, install [[http://caml.inria.fr|OCaml]], and simply run ''ocaml install.ml'' from the commandline. After that you'll get a ''./bin/haxe'' binary. You also need the files and directories inside the ''./std'' directory which contain the ''.hx'' standard Haxe library and other platform specific files.
< 
< Haxe is using ''neko'' to compile for server-side development. //Neko// binaries are also part of the //Haxe// distribution and must be downloaded from [[http://nekovm.org|NekoVM.org]] and compiled separately.
< 
< Here are more detailed instructions for each possible platform.
< 
< ====== Compile Haxe Tools ======
< 
< Two additional tools can be compiled : ''haxedoc'', the Haxe documentation generator and ''haxelib'', the Haxe library manager. You can compile these by going into the directory ''haxe/std/tools/haxedoc'' and ''haxe/std/tools/haxelib'' and by running the corresponding ''.hxml'' file. It will compile a binary executable file. You need Neko to be installed first.
< 
< ====== Windows / VisualC++ ======
< 
< To start with you should have [[http://msdn.microsoft.com/visualc/|Microsoft Visual Studio]] and [[http://www.tortoisecvs.org/|TortoiseCVS]] installed. If you install the [[http://www.microsoft.com/express/2005|free Visual C++ 2005 Express Edition]], you will also need to install the [[http://www.microsoft.com/downloads/details.aspx?FamilyID=7a1c9da0-0510-44a2-b042-7ef370530c64&DisplayLang=en|MASM (Microsoft Assembler)]] and [[http://www.microsoft.com/express/2005/platformsdk/default.aspx|Platform SDK]] (or use this [[http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en|older version]] if you're on Windows 2000). Note that [[http://www.microsoft.com/express/default.aspx|Visual C++ 2008 Express Edition]] won't work at present moment as you cannot install MASM into it.
< 
< Add ''C:\Program Files\TortoiseCVS'' [[http://support.microsoft.com/default.aspx?scid=kb;en-us;310519|to your PATH]].
< 
< [[http://caml.inria.fr/download.en.html|Download]] and install the [[http://caml.inria.fr/pub/distrib/ocaml-3.09/ocaml-3.09.0-win-msvc.exe|"Microsoft toolchain" version]] of [[http://caml.inria.fr/|Ocaml]].
< 
< 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 [[http://www.zlib.net/|zlib]] from [[http://www.zlib.net/zlib123-dll.zip|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:
< 
< <code>
< cd C:\haxe\
< SET LIB=%LIB%;"C:\haxe\zlib123-dll\lib"
< SET INCLUDE=%INCLUDE%;"C:\haxe\zlib123-dll\include"
< </code>
< 
< and now run the install:
< 
< <code>
< ocaml install.ml
< </code>
< 
< If you finish with:
< 
< <code>
< copy zlib123-dll\zlib1.dll bin
< </code>
< 
< 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!
< 
< ====== Windows / Cygwin ======
< 
< 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. 
< This tools are standar for compiling stuff, and ocaml is necesary for haxe compilation.
< 
< - You will also need zlib, you can install the cygwin one or get the latest version at [[http://www.zlib.net|zlib homepage]], download it and compile it.
< 
< - Put the install.ml in a folder, for example haxebuild.
< 
< - In such folder, create a bin folder, and a zlib folder. ( example /path/to/haxebuild/bin, /path/to/haxebuild/zlib)
< 
< - Inside the zlib dir, create symbolic links for /usr/include/zconf.h, /usr/include/zlib.h, /usr/lib/libz.a:
< <code>ln -s /usr/include/zconf.h zconf.h
< ln -s /usr/include/zlib.h zlib.h
< ln -s /usr/lib/libz.a libz.a</code>
< 
< After that you will need to modify install.ml
< 
< Comment the line that starts **#load "unix.cma".** Comments in this file begin with (* and end with *).
< So your line will read **(* #load "unix.cma" *)** .
< This is necessary because we are not compiling for a true unix environment. 
< 
< Uncomment the line that says 
< **let os_type = "Cygwin"**
< 
< Change the next line that says:
< **let obj_ext = match os_type with "Win32" -> ".obj"  | _ -> ".o"**
< for:
< **let obj_ext = match os_type with "Win32" -> ".obj" | "Cygwin" -> ".o" | _ -> ".o"**
< (you add the object extension for cygwin).
< 
< Change the sections that says:
< **let zlib_path = match os_type with**
< **        | "Win32" -> "../ocaml/extc/zlib/"**
< **        | _ -> "./"**
< for:
< **let zlib_path = match os_type with**
< **        | "Win32" -> "../ocaml/extc/zlib/"**
< **        | "Cygwin" -> "../zlib/"**
< **        | _ -> "./"**
< (You add the cygwin zlib path, the one with the symbolic links).
< 
< Change the section that says:
< **let zlib = match os_type with**
< **        | "Win32" -> zlib_path ^ "zlib.lib"**
< **        | _ ->**
< for:
< **let zlib = match os_type with**
< **        | "Win32" -> zlib_path ^ "zlib.lib"**
< **        | "Cygwin" -> zlib_path ^ "libz.a"**
< **        | _ ->**
< (added the cygwin file)
< 
< Around line 85 you'll find a line that says
< **cvs motiontwin "login";**
< 
< remove the word "login", (it caused trouble for me).
< 
< Comment the line that says:
< **(try Unix.mkdir "bin" 0o740 with Unix.Unix_error(Unix.EEXIST,_,_) ->());**
< 
< Write your changes and at the bash prompt type
< <code>ocaml install.ml.</code>
< 
< It will download the necesary sources from cvs, and then proceed to compile them.
< After compilation is done, you will have your brand new haxe.exe in the bin directory you created before.
< 
< Copy it to wherever you want, and don't forget the std dir also, as it's includes the haxe
< standard libraries.
< 
< ====== Windows / Mingw ======
< 
< Before starting, please read the notes below.
< 
< ==== 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 [[http://downloads.sourceforge.net/sourceforge/mingw/make-3.81-MSYS-1.0.11-2.tar.bz2|MSYS Make]].
< 
< ==== MinGW (Standard Install) ====
< 
< - Download [[http://downloads.sourceforge.net/sourceforge/mingw/MinGW-5.1.4.exe|MinGW]]
< - Donwload [[http://downloads.sourceforge.net/sourceforge/mingw/binutils-2.18.50-20080109-2.tar.gz|MinGW Binutils]]
< - Download [[http://downloads.sourceforge.net/sourceforge/mingw/mingw32-make-3.81-20080326-3.tar.gz|MinGW Runtime]]
< - Download [[http://downloads.sourceforge.net/sourceforge/mingw/w32api-3.11.tar.gz|MinGW Win32Api]]
< - Download [[http://downloads.sourceforge.net/sourceforge/mingw/mingw-utils-0.3.tar.gz|MinGW Utils]]
< - Download [[http://downloads.sourceforge.net/mingw/gdb-6.8-mingw-3.tar.bz2|MinGW GDB]]
< - Download [[http://downloads.sourceforge.net/mingw/mingw32-make-3.81-2.tar.gz|MinGW Make]]
< 
< - Download [[http://downloads.sourceforge.net/tdm-gcc/gcc-4.3.1-tdm-1-core.tar.gz|MinGW GCC 4.3.1 - core]]
< - Download [[http://downloads.sourceforge.net/tdm-gcc/gcc-4.3.1-tdm-1-g++.tar.gz|MinGW GCC 4.3.1 - g++]]
< 
< - Install MinGW and then simply extract all the other archives in your mingw directory.
< 
< ==== MSYS (Standard Install) ====
< 
< - Download [[http://downloads.sourceforge.net/sourceforge/mingw/MSYS-1.0.10.exe|MSYS]]
< - Download [[http://downloads.sourceforge.net/sourceforge/mingw/msysDTK-1.0.1.exe|MSYS DTK]]
< - Download [[http://downloads.sourceforge.net/sourceforge/mingw/bash-3.1-MSYS-1.0.11-1.tar.bz2|MSYS Bash]]
< 
< - Install MSYS then MSYS-DTK and extract the bash in your msys directory.
< 
< ==== OCaml ====
< 
< - Download  and install [[http://caml.inria.fr/pub/distrib/ocaml-3.10/ocaml-3.10.2-win-mgw.exe|MinGW-OCaml]]
< 
< ==== libZ ====
< 
< - Donwload [[http://downloads.sourceforge.net/sourceforge/mingw/zlib-1.2.3-MSYS-1.0.11-1.tar.bz2|MSYS zlib]]
< 
< //Note//: You can also download the latest [[http://www.zlib.net/zlib-1.2.3.tar.gz|zlib tarball]] and compile it under MinGW.
< 
< ==== GNUWIN32 (Optional) ====
< 
< - Download and install [[http://downloads.sourceforge.net/sourceforge/gnuwin32/wget-1.10.1.exe|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: 
< <code>export PATH=".:/usr/local/bin:/mingw/bin:/bin:/gnuwin32/bin:/ocaml/bin:$PATH"</code>
< 
< - 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 {{install.ml}}
< - Edit it, see below [1] the modifications to make in this file.
< 
< - Start MSYS terminal and type 
< <code>cd haxe</code>
< - Start the installation by typing 
< <code>OCAMLLIB="/ocaml/lib/" ocaml install.ml</code>
< - 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
< <code>OCAMLLIB="/ocaml/lib/" ocaml install.ml</code>
< - 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"**
< 
< [1] **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"**
< 
< [2] **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"**
< 
< ==== Links ====
< 
< - [[http://www.mingw.org|MinGW/MSYS Home Page]]
< - Latest [[http://sourceforge.net/project/showfiles.php?group_id=2435|MinGW/MSYS packages]]
< - Latest [[http://www.tdragon.net/recentgcc/|GCC for MinGW]]
< - [[http://gnuwin32.sourceforge.net/|GNUWin32 packages]]
< 
< 
< ====== Linux ======
< 
< The complete build and install process looks like (may contains some minor errors) :
< 
< <code>
< mkdir haxe
< cd haxe
< 
< # download and compile haxe, you may require some development libraries 
< # like libmysql, libz, libsqlite3, ... and of course ocaml
< wget http://haxe.org/_media/install.ml
< ocaml install.ml
< 
< # install haxe in /usr/local
< sudo mkdir /usr/local/haxe
< sudo mkdir /usr/local/haxe/bin
< sudo cp haxe/bin/* /usr/local/haxe/bin
< sudo cp -r haxe/std /usr/local/haxe
< sudo ln -s /usr/local/haxe/bin/haxe /usr/local/bin/haxe
< 
< # setup environment variables for haxe
< sudo grep "HAXE_LIBRARY_PATH" /etc/environment || echo "export HAXE_LIBRARY_PATH=/usr/local/haxe/std:." >> /etc/environment
< 
< # download and compile neko
< cvs -d:pserver:anonymous@cvs.motion-twin.com:/cvsroot login
< cvs -d:pserver:anonymous@cvs.motion-twin.com:/cvsroot co neko
< cd neko
< make
< 
< # install neko
< sudo mkdir /usr/local/neko
< sudo cp bin/* /usr/local/neko
< sudo ln -s /usr/local/neko/neko* /usr/local/bin/
< sudo ln -s /usr/local/neko/libneko.so /usr/local/lib
< 
< # may be required if /usr/local/lib is not in your library search path
< sudo grep "/usr/local/lib" /etc/ld.so.conf || echo "/usr/local/lib" >> /etc/ld.so.conf
< sudo ldconfig
< 
< # setup environment variables for neko
< sudo grep "NEKOPATH" /etc/environment || echo "export NEKOPATH=/usr/local/neko" >> /etc/environment
< </code>
< 
< Two quick notes about building Neko:
<   * Since subshell () is used in the Neko Makefile, you may get a segfault from bash because of insufficient stack. To avoid this problem, you can increase the stack size by 'ulimit -s 20000'.
<   * If you are not using gcc or an earlier gcc version, the option **-fno-stack-protector** may not be recognized. All you need to do is to removed it from the Neko Makefile. (Also comment it out in src/tools/neko.install, line 82 and 83).
< 
< 
< 
< ===== Apache2 =====
< 
< Using the debian/ubuntu apache2 configuration structure : 
< 
< <code>
< # add NEKOPATH variable to apache2 environment vars
< sudo grep "NEKOPATH" /etc/apache2/envvars || echo "export NEKOPATH=/usr/local/neko" >> /etc/apache2/envvars
< 
< # create a neko.conf in available modules
< sudo test -f /etc/apache2/mods-available/neko.conf || echo "AddHandler neko-handler .n" >> /etc/apache2/mods-available/neko.conf
< 
< # create a neko.load in available modules
< sudo test -f /etc/apache2/mods-available/neko.load || echo "LoadModule neko_module /usr/local/neko/mod_neko2.ndll" >> /etc/apache2/mods-available/neko.load
< 
< # enable neko module
< sudo ln -s /etc/apache2/mods-available/neko.* /etc/apache2/mods-enabled
< 
< # add index.n to DirectoryIndex in apache2.conf
< sudo grep "index.n" /etc/apache2/apache2.conf || cat /etc/apache2/apache2.conf | sed -r 's/^DirectoryIndex (.*?)/DirectoryIndex index.n \1/' > apache2.conf.tmp && cp apache2.conf.tmp /etc/apache2.conf 
< sudo test -f apache2.conf.tmp && rm apache2.conf.tmp
< 
< # restart apache2
< /etc/init.d/apache2 restart
< </code>
< 
< ====== Linux Debian (etch) ======
< 
< The complete build and install process looks like (may contains some minor errors) :
< 
< <code>
< mkdir haxe
< cd haxe
< 
< # download and compile haxe, you may require some development libraries 
< # like libmysqlclient15-dev, zlib1g-dev, libsqlite3-dev, ... 
< # and of course you require ocaml, ocaml-findlib and cvs
< wget http://haxe.org/_media/install.ml
< ocaml install.ml
< 
< # install haxe in /usr/local
< sudo mkdir /usr/local/haxe
< sudo mkdir /usr/local/haxe/bin
< sudo cp bin/* /usr/local/haxe/bin
< sudo cp -r haxe/std /usr/local/haxe
< sudo ln -s /usr/local/haxe/bin/haxe /usr/local/bin/haxe
< 
< # setup environment variables for haxe
< sudo grep "HAXE_LIBRARY_PATH" /etc/environment || echo "export HAXE_LIBRARY_PATH=/usr/local/haxe/std:." >> /etc/environment
< 
< </code>
< 
< ===== Neko from backports.org =====
< 
< Download and install neko from [[http://www.backports.org/dokuwiki/doku.php?id=instructions|Debian Backports]]
< 
< ====== OSX ======
< 
< ===== Building on Mac PPC =====
< 
< (Please list info here)
< 
< 
< ===== Building on Mac Intel =====
< 
< Building on Mac Intel requires an Intel build version of OCaml. You can download it from [[http://caml.inria.fr/pub/distrib/ocaml-3.10/]] or install it via [[http://www.macports.org/|Macports]] with ''port install ocaml''.
< 
< Once the local Intel build OCaml version is in place, proceed with downloading ''install.ml''. Create a folder where you'd like the sources to be downloaded to, and copy the ''.ml'' file there. Open ''install.ml'' and comment out line 20: ''(* #load "unix.cma" *)''.
< 
< Don't directly run the file but compile it first, using ''ocamlc unix.cma install.ml''. Next, run the compiled installer using ''$ ./a.out''
< 
< After a successful build, the Haxe compiler will be in the ''bin'' folder. 
< 
< In case you want to have the final std folder location other than ''/usr/lib/haxe/std/'' or ''/usr/local/lib/haxe/std/'' you need to change ''Plugin.class_path'' in ''main.ml'' to your preferred location and start over.  
< 
< ===== Creating a distribution =====
< 
< To have your local build packaged up for distribution you can use the PackageMaker project from [[http://code.google.com/p/haxe-osx-installer|this repository]]. Make sure to place the sources in a folder adjacent to your haxe build folder (i.e., if ''../projects/haxe'' is where you placed ''install.ml'' or checked out the Haxe sources using CVS, than the installed package sources should be at ''../projects/haxe-inst'') 
< 
< Be sure to modify the version numbers listed within the project file, and the ''INFO.txt'' file. Open ''haxe.pmproj'' with the PackageManager. Do a quick run-through through the PackageManager Interface Editor and resolve the hard-set paths on the background image, and the LICENCE.txt and INFO.txt files to your local paths. Once this maintenance is done, save the project but leave the PackageManager application without building the package.
< 
< Open a terminal window and go to the installer sources root folder. Type ''$ ./package'' . Your distribution should be ready (at ''haxe.pkg'').
< 
< ===== Creating a Universal distribution =====
< 
< Creating a Universal distribution only requires that you have a version of the Haxe compiler build for the opposite platform of your local build. So, if you build Haxe on Intel, ask someone on the list for the eqivalent PPC version - or vice versa. This way you'll end up with two versions of the Haxe compiler.
< 
< Open a terminal at the ''bin'' folder of your Haxe source folder. Rename ''haxe'' to either ''haxe_ppc'' or ''haxe_i386'', depending on your platfrom. Next copy the haxe compiler for the opposite platform to the folder. Rename this file either ''haxe_i386'' or ''haxe_ppc''.
< 
< Run ''$ lipo -create -arch ppc haxe_ppc -arch i386 haxe_i386 -output haxe'' to have the two versions merged into one single Universal executable (''haxe'').
< 
< Continue creating your distribution as outlined at ''Creating a distribution''. Don't worry about making ''haxelib'' and ''haxedoc'' Universal: they already, are since the underlying Neko binaries are.
\ No newline at end of file
---
> [[../doc/build]]
\ No newline at end of file

	
Ver Date User Action
#15806 2012-12-20 09:20:19 ppelleti View | Diff
#15209 2012-07-28 16:22:56 jan_flanders View | Diff
#8924 2010-08-02 00:41:19 dannyLopez View | Diff
#8923 2010-08-02 00:33:50 dannyLopez View | Diff
#7389 2009-12-20 02:45:26 Floppya View | Diff
#5002 2008-11-24 23:28:42 NemeaLion Restored to version #4307
#4633 2008-10-07 05:02:54 baurel Deleted
#4601 2008-10-07 04:22:44 baurel View | Diff
#4526 2008-10-07 02:45:56 baurel Deleted
#4307 2008-09-24 21:03:10 NemeaLion View | Diff
#4278 2008-09-22 02:49:59 NemeaLion View | Diff
#1734 2008-07-11 13:22:43 zaijian View | Diff
#1733 2008-07-11 13:20:23 zaijian View | Diff
#1732 2008-07-11 13:13:54 zaijian View | Diff
#1731 2008-07-11 13:08:02 zaijian View | Diff
#1730 2008-07-11 13:02:59 zaijian View | Diff
#1176 2008-05-03 14:54:41 ponticelli View | Diff
#1175 2008-05-03 14:54:41 ponticelli Set title to Compiling Haxe

Previous | Next