Blog Categories
Ad Space
Twitter Updates
    follow me on Twitter
    Currently Reading
    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_R13B.tar.gz | tar zx
    cd otp_src_R13B
    ./configure --enable-hipe
    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 ..
    

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

    For a web framework I recommend Nitrogen. It's by far the most interesting at the moment.

    git clone git://github.com/rklophaus/nitrogen.git nitrogen-master
    cd nitrogen-master
    make
    cd ..
    

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

    mochiweb:module_info().
    mysql:module_info().
    wf:module_info().
    

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

    Reader Comments (13)

    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!

    Aug 11, 2008 at 5:48 | 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.

    Aug 11, 2008 at 16:24 | 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.

    Aug 12, 2008 at 23:22 | 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.

    Aug 13, 2008 at 9:13 | Registered CommenterJón Grétar Borgþórsson

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

    Aug 14, 2008 at 21:22 | Unregistered Commenteranselmo

    i'm also new to erlang and OSX. I had tried installing with a few other options but didn't quite work, so thanks a lot. Thanks for suggesting the libraries also. We use Mochiweb and Mnesia at work, will also try EUnit.

    Dec 21, 2008 at 13:41 | Unregistered CommenterSushant

    This was a nice blog. I would also like to say thanks for this blog post! Really helpful for a beginner of this stuff. Already knows some Erlang but looks forward to applying it in the my personal web apps, seems pretty nifty.

    Feb 24, 2009 at 23:30 | Unregistered CommenterViddo

    Excellent and very useful post - I'm just getting started with Erlang, and this helped greatly.
    Cheers

    Feb 26, 2009 at 21:12 | Unregistered CommenterDaren

    Very useful. I used these instructions to install R12B-5 on my Macbook Pro running Leopard. The only surprise is that erl shell takes from 5 to 7 full seconds to start - why sooooo long? Any insights will be appreciated!

    Mar 6, 2009 at 3:45 | Unregistered CommenterAlex

    I tried building erlang under leopard.

    No Makefile in the directory.

    Macintosh:otp_src_R12B-4$ make
    make: *** No targets specified and no makefile found. Stop.

    Please cc any reply to kashkoa@yahoo.com.

    Thank you

    Mar 8, 2009 at 13:52 | Unregistered CommenterAlex K

    Alex: I have absolutely no idea. erl start within 1 second for me.

    AlexK: Sounds a bit like you forgot to run the ./configure command first.

    Mar 8, 2009 at 21:35 | Registered CommenterJón Grétar Borgþórsson

    I tried a few times.

    ./configure fails with message

    "Compiler could not create executables"

    tried with sudo and making directory world readaable (chmod +777 equivalent)

    Mar 10, 2009 at 23:22 | Unregistered CommenterAlex K

    Thanks! Very clear and simple installation guide. I used the following configuration options:
    ./configure --enable-hipe --enable-smp-support --enable-threads

    May 27, 2009 at 23:31 | Unregistered CommenterStephan

    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>
    Fork me on GitHub