Building Erlang on OS X Lion

I’ve updated to the shiny new OS from Apple and I needed to use the language of the devilErlang. Unfortunately, there was no binary package for OS X, so I needed to compile it from the sources.
If you need to do the same yourself, you will need XCode 4.1 (get it for free in the App Store). This installs, amongst others, LLVM build 2335.15.00 gcc. Unfortunately, LLVM build 2335.15.00 is too new to build Erlang and the build fails. I did not want to install older gcc, but there is a simpler solution.

First make sure you’re running these commands on freshly untarred sources. It is not enough to run make clean, the Erlang’s makefile does not clean up everything properly. Now, once you’re in the directory where you uncompressed Erlang’s sources, run (notice setting the CFLAGS environment variable)

otp-sources $ CFLAGS=-O0 ./configure --prefix=/usr/share/erlang \
--enable-threads --enable-darwin-64bit


This will prepare the makefile for your platform; to compile & install simply run

make ; sudo make install


To complete the configuration of your system, you may want to consider adding entries to /etc/profile

ERLANG_HOME=/usr/share/erlang
PATH=…:$ERLANG_HOME/bin

This entry was posted in Jan's Blog and tagged , . Bookmark the permalink.

2 Responses to Building Erlang on OS X Lion

  1. Andrew Chalkley says:

    brew install erlang

    :)

  2. I’d never have guessed this was an optimization flag. Thanks for posting this.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>