Blog Categories
Ad Space
Twitter Updates
Powered by Squarespace
Git Projects
« Erlang Introduction (For the Ruby Guy) part 2 | Main | Erlang Introduction (For the Ruby Guy) part 1 »
Wednesday
06Aug

Installing Erlang and a few libraries on Mac OS X

Install Erlang

Lets start with installing the basic Erlang runtime.

cd /tmp
curl http://erlang.org/download/otp_src_R12B-4.tar.gz | tar zx
cd otp_src_R12B-4
./configure --enable-hipe  --enable-darwin-universal
make
sudo make install

To verify that everything is installed enter the command erl. You should be greeted with the erlang shell. You can exit it by entering the shortcut "q()." without the quotes (remember the period).

Install a Few Must Have Libraries

Now lets install a few libraries that it is likely that you will want to try out. First of all follow the instructions here to add your own library path. Now enter it and add the modules:

mkdir -p /Library/Erlang/lib
cd /Library/Erlang/lib

The first thing we want is the the Mochiweb library. Mochiweb is a simple but powerful http server.

sudo svn co http://mochiweb.googlecode.com/svn/trunk/ mochiweb-trunk
cd mochiweb-trunk
sudo make
cd ..

Next is the EUnit library. EUnit is a powerful unit testing library for Erlang.

sudo svn co http://svn.process-one.net/contribs/trunk/eunit eunit-trunk
cd eunit-trunk
sudo make
cd ..

If you have some legacy data you need to access in a MySQL database you will need the MySQL library. For new projects you propably are going to want to use Mnesia.

sudo svn co http://erlang-mysql-driver.googlecode.com/svn/trunk/ mysql-trunk
cd mysql-trunk
sudo mkdir ebin
sudo erlc -o ebin src/mysql.erl
sudo erlc -o ebin src/mysql_auth.erl
sudo erlc -o ebin src/mysql_conn.erl 
sudo erlc -o ebin src/mysql_recv.erl
cd ..

Now everything should be set up and ready. Lets try it by entering the following commands in the erl shell:

mochiweb:module_info().
eunit:module_info().
mysql:module_info().

If any are not installed correctly you will receive single line with an exception error.

EDIT 2008-09-03: Updated for R12B-4


Reader Comments (5)

Cool! As a newbie to both Erlang and OS X (started learning Erlang a few weeks ago, my first Mac arrived a few days ago =P), this tutorial was quite useful. Thanks!

August 11, 2008 | Unregistered Commenterzuwiki

You should probably make note of the fact that HiPE support for OS X on Intel macs is currently broken. It will compile, but throw a core dump when you try to run the Erlang code compiled by HiPE.

August 11, 2008 | Unregistered Commenterevgen

Thanks for the article. You said to enable hipe, what does that give you?

I would also like to add that while you can install erlang as you have done, there is a MacPort version as well.

August 12, 2008 | Unregistered CommenterAdam Christensen

HiPE is a native code compiler for Erlang. It's quite faster than the virtual machine version.

The MacPorts package has had some problems in installation. Heard that it was fixed but I still prefer this.

August 13, 2008 | Registered CommenterJon Gretar

Thanks, keep posting this stuff..... this is a reference

August 14, 2008 | Unregistered Commenteranselmo

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>