Skip to content

Getting started on Mac OS X

juj edited this page Feb 26, 2013 · 5 revisions

This guide instructs step-by-step on how to setup emscripten on a clean Mac OS X box. The steps have been tested against OS X version 10.8.2.

  1. Install svn if you do not have it yet. It is distributed with XCode Command Line Tools in OSX App Store. See http://superuser.com/questions/455214/where-is-svn-on-os-x-mountain-lion
  • Install XCode from OSX App Store.
  • In XCode->Preferences->Downloads, install Command Line Tools.
  • Test that svn works from command line: type 'svn --version' in terminal.
  1. Install git if you do not have it yet:
  1. Install cmake if you do not have it yet:
  1. Build LLVM+Clang 3.2 from SVN repository:

After these steps, Clang 3.2 will be built into ~/llvm32build/bin. The source tree ~/llvm32 is not needed anymore, if you want to conserve disk space.

Note that XCode ships with a custom version of Clang (3.1svn or 3.2svn depending on XCode version). It may be possible to omit this step and just use the version provided by XCode, but the LLVM 3.2 RELEASE version is preferred, since that is the "officially supported version" the emscripten OSX unit tests are run against.

  1. Set up Clang 3.2 in PATH:
  • cd ~

  • echo "export PATH=~/llvm32build/bin:$PATH" >> .profile

    The above change is permanent and it persists between system restarts. It only affects the current user.

  1. Close all terminal windows, and open a new one. Check that clang works ok in path:
  • cd ~

  • clang --version

    The command should output: clang version 3.2 (tags/RELEASE_32/final 176107) Target: x86_64-apple-darwin12.2.1 Thread model: posix

  1. Delete old .emscripten file if it happened to exist:
  • rm ~/.emscripten
  • rm -rf ~/.emscripten_cache
  1. Set up node:
  • Download and install node from http://nodejs.org/
  • Test that node works from command line: type 'node --version' in terminal.
  1. Obtain emscripten:
  • cd ~

  • git clone https://github.com/kripken/emscripten.git

    By default, git will clone the emscripten 'incoming' branch, which is the branch where the newest developments of emscripten occur. If you want to use a more stable branch, switch to the 'master' branch:

  • cd ~/emscripten

  • git checkout master

  1. Setup 'python2': (this step is needed to workaround a bug reported in #763)
  • In terminal, type 'python2 --version'. If you get a "command not found", type the following:
  • cd /usr/bin
  • sudo ln python python2
  • sudo ln ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 python22.7
  • Issue 'python2 --version' again. It should now print Python 2.7.2
  1. Perform emscripten "first run":
  • cd ~/emscripten
  • ./emcc --help
  • edit the file ~/.emscripten in a text editor to set up any required paths.
  1. (Optional) Compile a simple test program to check that everything works:
  • cd ~/emscripten

  • ./em++ tests/hello_world.cpp

  • node a.out.js

    The first run will most likely pop up an automatic prompt that asks to install java. Proceed, and after installation finishes, rerun the above commands. Running node should output: hello, world!

  1. (Optional) Compile a simple WebGL program to check that .html output and GLES2/WebGL works:
  • cd ~/emscripten

  • ./emcc tests/hello_world_gles.c -o hello_world_gles.html

  • open hello_world_gles.html

    If the Safari 6 browser pops up with a message "Could not create canvas :(", follow these instructions to enable WebGL support in Safari: http://support.apple.com/kb/PH11926

  1. (Optional) Run the full battery of tests to check that emscripten is perfectly operational on the current platform: