Stratus3D

Software Engineering, Web Development and 3D Graphics

Install Erlang 16 on Mac OSX 10.9 With Kerl

I recently was working on a project that required me to connect to an ODBC database. I hadn’t ever worked with ODBC before, but I saw Erlang had an application for interacting with ODBC databases. I fired up the Erlang console and typed odbc:module_info(). but the function was undefined. After double checking everything and trying to start the odbc application I realized that the odbc module wasn’t part of my Erlang installation. I tried reinstalling Erlang but that didn’t fix the problem. Turns out Erlang’s ODBC application relies on unixodbc, which isn’t included on OSX anymore. Here is how you get Erlang R16B03-1 on Mac OSX 10.9.5:

I use Kerl for building and installing Erlang versions. It’s a relatively simple tool that I have found to be very helpful. I am assuming you are using Kerl in the steps below. If you aren’t using Kerl it should still be possible to build Erlang with ODBC support on OSX, but you will need to alter these commands appropriately. I also assume you are using brew.

  1. Brew does all the hard work for us. Run $ brew install freetds. Make sure freetds was installed successfully and then try running $ tsql. If tsql exists it should print out some help information.
  2. We can use brew install unixodbc. Run $ brew install unixodbc. Make sure it installs successfully and then verify by running $ isql. isql should print out some help information.
  3. Install Erlang with Kerl. Before you build Erlang open up ~/.kerlrc (or create it if it doesn’t exist) and make sure it looks like this:

         KERL_CONFIGURE_OPTIONS="--enable-darwin-64bit --disable-hipe --enable-vm-probes --with-dynamic-trace=dtrace --disable-native-libs --enable-kernel-poll --enable-threads --enable-smp-support --with-wx"
    

    Also, one more thing before running the build command - make sure $GREP_OPTIONS is set to ''. On my system I had customized it and it was causing the build to crash:

         GREP_OPTIONS=''
    

    Finally, you should be able to run the build command. Here I chose erlang_16 as the build name:

         kerl build R16B031 erlang_16
    
  4. If all goes well you should be able to install the build by running kerl install erlang_16 <dir> where <dir> is the directory you want to install the build in. You should now have an installation that includes the odbc application!

If this quick post wasn’t able to help you here are some other resources I found that helped me fix this issue: