Skip to content

Instantly share code, notes, and snippets.

@jj1bdx
Last active December 16, 2015 13:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jj1bdx/5441077 to your computer and use it in GitHub Desktop.
Save jj1bdx/5441077 to your computer and use it in GitHub Desktop.
[ja] Mac OS XのErlang R15B03-1でwxを動かすための方法

ErlangのグラフィックライブラリwxをMacBookAirで使えるようにする

必要なもの

  • Mountain Lion (OS X 10.8.x 使ったのは 10.8.3 / 10.8.5)
  • Xquartz http://xquartz.macosforge.org/landing/ からダウンロードしてインストール
  • HomeBrew http://mxcl.github.io/homebrew/
    • 入れ方は ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
  • kerl https://github.com/spawngrid/kerl
    • ダウンロードは curl -O https://raw.github.com/spawngrid/kerl/master/kerl
    • 落としてきたバイナリを適当なところに置いて chmod u+x kerl しておけばOK
  • git
    • brew install git

作業手順

  • brew install wxgtk.rb
    • これで /usr/local/Cellars/wxgtk/2.8.12 の下にインストールされる
  • kerl を使って,必要なパッチの当たった R15B03-1 を持ってくる.
    • kerl は git 経由でのインストールに対応している.
    • インストール時に configure に与えるパラメータは 環境変数 KERL_CONFIGURE_OPTIONS で指定できる
    • 実際のコマンドは以下の通り (R15B03-1の場合,R16BやR16B02の時は kr-r16b-osx-wx / kr-r16b02-osx-wx に変更)
            env KERL_CONFIGURE_OPTIONS="--enable-darwin-64bit \
                              --disable-hipe \
                              --enable-vm-probes \
                              --with-dynamic-trace=dtrace \
                              --disable-native-libs \
                              --disable-hipe \
                              --enable-kernel-poll \
                              --without-odbc \
                              --enable-threads \
                              --enable-smp-support \
                              --with-wxdir=/usr/local/Cellar/wxgtk/2.8.12 \
                              --with-wx-config=/usr/local/Cellar/wxgtk/2.8.12/bin/wx-config" \
             kerl build git https://github.com/jj1bdx/otp kr-r15b03-1-osx-wx kr-r15b03-1-osx-wx
      
    • これで ~/.kerl/builds/kr-r15b03-1-osx-wx の下にビルドした実体ができるので,インストールする.
    • たとえば /Users/kenji/otp/r15b03-1 の下に入れたい時は以下のようにする
             kerl install kr-r15b03-1-osx-wx /Users/kenji/otp/r15b03-1
      
    • このkerlで入れたディストリビューションを有効にしたいときは,シェルから
             . /Users/kenji/otp/r15b03-1/activate
      
    とすればよい.

テストの仕方

  • Erlangのプロンプトが出てきたら wx:demo(). と実行

R16B の場合は wxmac を使うのもあり

  • brew install wxmac を実行するとwxWidgets 2.9 が入る
  • R16Bなら --with-wxdir --with-wx-config なしでインストールすればOK
  • wxmac 2.9.5.0 はリンクはできるが起動しないという問題がある

どんなパッチを当てたか

[以上]

require 'formula'
class Wxgtk < Formula
homepage 'http://www.wxwidgets.org'
url "http://downloads.sourceforge.net/project/wxwindows/2.8.12/wxGTK-2.8.12.tar.gz"
sha1 '56cc7f6622dd6f2fecd43fc210dc1c6cb155b37f'
keg_only 'This formula conflicts with wxwidgets 2.9 and by now is only used by erlang'
depends_on :x11 # if your formula requires any X11/XQuartz components
depends_on 'gtk+'
depends_on 'pkg-config' # これを書かないと,インストールできたふりをして,できていないという問題が起こる
def install
args=[
"--with-libpng",
"--with-opengl",
"--with-libjpeg",
"--with-libtiff",
"--with-freetype",
"--with-zlib",
"--enable-unicode",
"--disable-debug",
"--prefix=#{prefix}",
"--with-gtk"
]
ENV.append 'LDFLAGS', '-lX11 -lGL -lGLU'
system "./configure", *args
system "make install"
cd "contrib" do
system "make"
system "make install"
end
end
end
@majimenezp
Copy link

if have problems with this error message:
make: *** [.pch/wxprec_advdll/wx/wxprec.h.gch] Error 1
clang: error: cannot specify -o when generating multiple output files
make: *** [.pch/wxprec_htmldll/wx/wxprec.h.gch] Error 1
clang: error: cannot specify -o when generating multiple output files
make: *** [.pch/wxprec_qadll/wx/wxprec.h.gch] Error 1

Try to add the argument:
-disable-precomp-headers

In the args of the formula.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment