Saturday, September 29, 2012



1.- Erlang can be compiled directly from the latest stable source. Go to the site: 

Download the latest source file, and extract to a directory of your choice. When I downloaded the file "otp_src_R15B01.tar" was the latest, but now there seems to be a newer version. 

2.- To compile the code you will need the developer command line tools, and these tools come with Xcode. if you don't have it already; download and Install Xcode from here:

Xcode is free, and can also be downloaded from the AppStore. Once you have downloaded Xcode, open it, go to preferences then downloads. There is an "Install" link to add the command line tools.

Once this has been completed, make sure to re-open your terminal window.

3.- Open terminal and go to the directory where you extracted the source code and run:

./configure
make
sudo make install

4.- To verify installation just open the terminal and type erl. You should see something like this:  

Nicolass-MacBook-Pro:~ nicolaslarrea$ erl
Erlang R15B01 (erts-5.9.1) [source] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
1>

5.- A lot of Erlang developers use Emacs, and if your using a Mac computer, then Acuamacs is the best choice. To Install Acuamacs go to: 

6.-To configure Acuamacs for Erlang you will need to create the folder “Aquamacs Emacs” in the following path

/Library/Preferences/Aquamacs Emacs

Then create the file Preferences.el specifying the paths where Erlang resides: 

;; Erlang mode
(setq load-path (cons"/usr/local/lib/erlang/lib/tools-2.6.7/emacs" load-path))
(setq erlang-root-dir "/usr/local/lib/erlang")
(setq exec-path (cons "/usr/local/lib/erlang/bin" exec-path))
(require 'erlang-start)

These paths are specific to the version of Erlang that I installed (R15B01), for different versions, double check the paths are correct. 

Finally, save the file in: /Library/Preferences/Aquamacs Emacs/ Preferences.el  

8.-Open Acuamacs and create a hello.erl

-module(hello).
-export([hello_world/0]).

hello_world() -> io:fwrite("hello world!\n").

An Erlang menu should be created right beside the Tools menu, and the syntax coloring should be activated.

9.- To compile the code go to Erlang -> Compile -> Compile Buffer, or press Ctrl-C + Ctrl-K.

10.- Finally, type in the shell:

hello:hello_world().

It should look something like this: