Installing Erlang and a few libraries on Mac OS X
Wednesday, August 6, 2008 at 21:34 by
Jón Grétar Borgþórsson 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 (19)
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!
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.
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.
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.
Thanks, keep posting this stuff..... this is a reference
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.
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.
Excellent and very useful post - I'm just getting started with Erlang, and this helped greatly.
Cheers
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!
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
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.
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)
Thanks! Very clear and simple installation guide. I used the following configuration options:
./configure --enable-hipe --enable-smp-support --enable-threads
Helped me to install Erlang on my Snow Leopard - went very smooth - wonderful! Thanks a lot
I found this post to be excellent. I really like how you added the must have packages.
Great post, thx. But i have a little problem:
after installing MySQL i get
Eshell V5.7.1 (abort with ^G)
1> mysql:module_info().
** exception error: undefined function mysql:module_info/0
2> q().
ok
Some help pls?
@da
I get the same error:
1> mysql:module_info().
** exception error: undefined function mysql:module_info/0
Hi. Tried this on my MacBook with Snow Leopard 10.6.2 with XCode installed from OS X Snow Leopard distribution disk. Got a bunch of errors on the make step:
In file included from /usr/include/wx-2.8/wx/mac/glcanvas.h:4,
from /usr/include/wx-2.8/wx/glcanvas.h:60,
from gen/../wxe_impl.h:23,
from gen/gl_funcs.cpp:23:
/usr/include/wx-2.8/wx/mac/carbon/glcanvas.h:49: warning: ‘AGLDrawable’ is deprecated (declared at /System/Library/Frameworks/AGL.framework/Headers/agl.h:48)
/usr/include/wx-2.8/wx/mac/carbon/glcanvas.h:53: warning: ‘AGLDrawable’ is deprecated (declared at /System/Library/Frameworks/AGL.framework/Headers/agl.h:48)
gen/gl_funcs.cpp: In function ‘void gl_dispatch(int, char*, ErlDrvTermData, WXEBinRef**)’:
gen/gl_funcs.cpp:4563: error: cast from ‘void*’ to ‘int’ loses precision
gen/gl_funcs.cpp:4578: error: cast from ‘void*’ to ‘int’ loses precision
gen/gl_funcs.cpp:4587: error: cast from ‘void*’ to ‘int’ loses precision
gen/gl_funcs.cpp:4652: error: cast from ‘void*’ to ‘int’ loses precision
make[3]: *** [i386-apple-darwin10.2.0/gl_funcs.o] Error 1
make[2]: *** [opt] Error 2
make[1]: *** [opt] Error 2
make: *** [libs] Error 2
Any ideas what went wrong?
Did you manually install wxWidgets from somewhere?
Try going to the source directory and typing "
touch lib/wx/SKIP".No one really uses Erlang for designing graphical programs anyway.