Last-modified: 2014-11-17 (月) 21:22:35
emscripten/インストール

概要

OS Xにemscriptenをインストールします。

手順

  1. インストール
    Everything is expanded.Everything is shortened.
      1
      2
    
    -
    !
    
    # llvm --with-clangにするとclangも入るのがもの凄く時間がかかる
    brew install llvm emscripten node
  2. シンボリックリンク作成
    with-clangしない場合のみ必要
    Everything is expanded.Everything is shortened.
      1
      2
    
    -
    !
    
    # /usr/binにあるxcodeで入っているclangを使う
    sudo ln -s /usr/bin/clang* /usr/local/Cellar/llvm/3.5.0/bin/
  3. .emscripten編集
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
    
    -
    !
     
     
     
    
    # 初回に.emscriptenが作成される
    em++
     
    vi .emscripten
    LLVM_ROOT = '/usr/local/Celler/llvm/3.5.0/bin/'
  4. 動作確認用コード作成
    test.cppとして作成
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
    
     
     
     
     
     
    -
    |
    |
    !
    
    #include <iostream>
     
    using namespace std;
     
    int main()
    {
        cout << "foo\n";
        return 0;
    }
  5. ビルド
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
    
    -
    !
     
    -
    !
     
    -
    !
    
    # jsコードを含まない場合は、先にclang++でビルドできるか確認したほうが問題の切り分けがしやすい
    clang++ -stdlib=libc++ -std=c++11 -O1 test.cpp -o test
     
    # jsファイルを作成
    EMCC_FAST_COMPILER=0 em++ -stdlib=libc++ -std=c++11 -O1 test.cpp -o test.js
     
    # 確認
    node test.js

検証時の環境

参考