HOWTO: Getting wx to work with Erlang on OS X
UPDATE: Since I wrote this Erlang Solutions has shipped a new 32-bit OS X build that works with wx out of the box.
Erlang ships with both wx and tk GUI apps, but the tk ones are deprecated and will be removed soon.
Unfortunately neither the Erlang OS X build from Erlang Solutions nor the one from Homebrew nor the default kerl build support wx on OS X, they all fall back to tk.
I spent an afternoon figuring out how to get Erlang on OS X working with wx and this is the result:
And here’s what to do:
I’m going to use homebrew to install wxmac, but the wxmac recipe needs patching before it will work with Erlang. You can either manually apply the changes from my commit or just run
brew install https://raw.github.com/MSch/homebrew/master/Library/Formula/wxmac.rb --disable-monolithic
Once that’s done, I’ll use kerl to install Erlang. You can get that easily via homebrew too:
brew install kerl
Via trial and error I found out that these configure options work. Just put the following in your
KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac --enable-shared-zlib --enable-dynamic-ssl-lib --enable-hipe --enable-smp-support --enable-threads --enable-kernel-poll --with-wx"
CPPFLAGS="-arch i386" kerl build R16B02 R16B02.x86.wx
CPPFLAGSis necessary, otherwise (e.g. with
--enable-darwin-universal) it didn’t work for me. And yes, I’m building a 32-bit Erlang, I didn’t manage to get 64-bit to work, it always crashed when starting wx.
Since kerl makes it easy to have multiple Erlang installs on one machine only using the 32-bit one for the wx GUI tools and connecting it to another local node should be an options if you want 64-bit Erlang on your dev machine.
Install and activate Erlang
sudo kerl install R16B02.x86.wx /opt/erlang/R16B02.x86.wx/ . /opt/erlang/R16B02.x86.wx/activate
Enjoy your new wx-enabled Erlang
erl -s observer start