Building Haxe on Ubuntu / Debian
You are viewing an old version of this entry, click here to see latest version.
Debian / Ubuntu
Prerequisities
The Haxe compiler is written in the OCaml language. Therefore we have to install Ocaml first. Additionally we make sure to have the most important tools and libraries installed.
sudo apt-get install ocaml camlp4 ocaml-findlib cvs zlib1g-dev make wget tar subversion
Make sure to uninstall existing versions of Haxe which you may have previously installed via .deb packages or manually.
sudo apt-get remove haxe
and
sudo rm -rf /usr/lib/haxe sudo rm -rf /usr/bin/haxe*
Installation
You can use the following shell script which handles the complete process. It will download the haxe source, build haxe and install it.
installation script:
#!/bin/sh # installhaxe.sh # # Build the haxe compiler # ===================== # - download 'install.ml' and execute it (compiles the haxe compiler) # - copy the executables and modifies the evironment variables # My libz was in a different place, maybe uncommenting helps # sudo ln -s /usr/lib/i386-linux-gnu/libz.so /usr/lib/libz.so mkdir haxesrc cd haxesrc wget http://haxe.googlecode.com/svn/trunk/doc/install.ml ocaml install.ml # reset previous installations sudo rm -rf /usr/local/haxe sudo rm -rf /usr/local/bin/haxe* # 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 grep "HAXE_LIBRARY_PATH" /etc/environment || echo "export HAXE_LIBRARY_PATH=/usr/local/haxe/std:." | sudo tee -a /etc/environment
1. copy the contents of the installation script into a shell script, like installhaxe.sh
vim installhaxe.sh
2. make it executable:
sudo chmod 0755 installhaxe.sh
3. run it:
./installhaxe.sh
Environment variables
The following two variables should be defined in the etc/profile file:
1.) $HAXE_LIBRARY_PATH
Please make sure that the haxe compiler finds its libraries (the std folder) by correctly setting this environment variable.
2.) $HAXE_HOME
Additionaly it doesn't hurt to define the location of your Haxe installation.
# in /etc/profile # ... export HAXE_LIBRARY_PATH=/usr/local/haxe/std:. # the ':.' part is important export HAXE_HOME=/usr/local/haxe PATH=$PATH:$HAXE_LIBRARY_PATH:$HAXE_HOME/bin
Final function test
Please run this little test to see if Haxe is able to compile your code.
File Test.hx :
class Test { static function main() { trace("Hello World !"); } }
File compile.hxml :
-js test.js -main Test
Run from command line:
haxe compile.hxml
File index.html :
Html code for testing the JavaScript:
<html> <head> <title>Haxe JS</title> </head> <body> <div id="haxe:trace"></div> <script type="text/javascript" src="test.js"></script> </body> </html>
version #15309, modified 2012-08-09 22:13:18 by jan_flanders