Contents
- X11 for Mac OS X install
- Ruby 1.8.2 install
- ranlibって何してるの?
- SDL
- 古いRubyをruby16にしておく。
- Ruby/OpenGL install
- Ruby/Math3D install
- patchをあててない場合、
- Ruby/SDL install
- patchをあててない場合、
- rsdl install
- rsdlの動作確認
Ruby/SDL on Mac OS X
Ruby/SDLをMac OS X上で動かす。 他のマシンでは簡単に動くのだが、Mac OS Xだとなぜかめんどい。
ここの記述を参考に、動かしてみる。
■X11 for Mac OS X install
Ruby/OpenGLのinstallにはX11が必要。
以前はここからダウンロードできたのだが、できなくなっている。
- http://www.apple.com/downloads/macosx/apple/x11formacosx.html
- http://wsidecar.apple.com/cgi-bin/nph-reg3rdpty1.pl/product=02232&platform=osx&method=sa/X11User.dmg
% wget "http://wsidecar.apple.com/cgi-bin/nph-reg3rdpty1.pl/product=02232&platform=osx&method=sa/X11User.dmg"
としてダウンロードして、実行する。
また、Ruby/SDLでOpenGLを使っているプログラムは、実行環境においてもX11 がinstallされている必要がある。installされてないと、下記のようなエラー メッセージが表示される。
% rsdl testgl.rb dyld: sgl can't open library: /usr/X11R6/lib/libGLU.1.dylib (No such file or directory, errno = 2) Trace/BPT trap
実行環境においても、X11がinstallされている必要があります。
■Ruby 1.8.2 install
まずは,Ruby 1.8.2のinstall
% wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.2.tar.gz % tax ruby-1.8.2.tar.gz % cd ruby-1.8.2 % setenv CFLAGS '-g -O2 -fno-common' →これが無いとRubyCocoa.frameworkと接続できないそうだ。 % ./configure; make; make test % sudo make install % sudo ranlib /usr/local/lib/libruby-static.a
これでinstall完了.
/usr/local/lib/libruby-static.a
というファイルができるので,これを元にrsdlを作れる. 最後になぜranlibしてるかしらん。
ranlibって何してるの?
% ls -l /usr/local/lib/libruby-static.a -rw-r--r-- 1 root staff 2386700 Apr 5 12:08 /usr/local/lib/libruby-static.a % sudo ranlib /usr/local/lib/libruby-static.a % ls -l /usr/local/lib/libruby-static.a -rw-r--r-- 1 root staff 2386700 Apr 5 21:49 /usr/local/lib/libruby-static.a
なにが変化したのか,よくわからず.
■SDL
% wget http://www.libsdl.org/release/SDL-1.2.8.tar.gz % tax SDL-1.2.8.tar.gz % cd SDL-1.2.8 % ./configure; make % sudo make install
■古いRubyをruby16にしておく。
# cd /usr/bin # ls -l ruby -rwxr-xr-x 1 root wheel 591592 Jan 19 01:45 ruby* # mv ruby ruby16
■Ruby/OpenGL install
前述のように、X11 for Mac OS Xがはいってないとcompileできない。
% wget http://www2.giganet.net/~yoshi/rbogl-0.32f.tar.gz % cd opengl-0.32f ←変則的 % ruby extconf.rb; make % sudo make install install -c -p -m 0755 opengl.bundle /usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin7.7.0
■Ruby/Math3D install
一応いれておく.
% wget http://www2.giganet.net/~yoshi/math3d-0.04.tar.gz % tax % cd math3d-0.04
patchをあてる.
--- ./extconf.rb.org Wed Apr 6 10:46:40 2005 +++ ./extconf.rb Wed Apr 6 10:46:52 2005 @@ -7,2 +7,3 @@ +CFLAGS = [] CFLAGS << " -Wall -Wno-comment"
% ruby extconf.rb; make % sudo make install install -c -p -m 0755 math3d.bundle /usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin7.7.0
patchをあててない場合、
エラーがでます。
■Ruby/SDL install
% wget http://www.kmc.gr.jp/~ohai/rubysdl/rubysdl-0.9.4.tar.gz % tax rubysdl-0.9.4.tar.gz % cd rubysdl-0.9.4
patchをあてる。
*** ./extconf.rb.org Thu Apr 21 17:29:48 2005 --- ./extconf.rb Thu Apr 21 17:31:57 2005 *************** *** 3,8 **** --- 3,9 ---- sdl_config = with_config('sdl-config', 'sdl-config') $CFLAGS += ' ' + `#{sdl_config} --cflags`.chomp + $CFLAGS += " -no-cpp-precomp" $LOCAL_LIBS += ' ' + `#{sdl_config} --libs`.chomp if /-Dmain=SDL_main/ =~ $CFLAGS then
% ruby extconf.rb; make checking for SMPEG_new() in -lsmpeg... no checking for Mix_OpenAudio() in -lSDL_mixer... no checking for sge_Line() in -lSGE... no checking for IMG_Load() in -lSDL_image... no checking for TTF_Init() in -lSDL_ttf... no checking for TTF_OpenFontIndex()... no checking for TTF_FontFaces()... no checking for TTF_FontFaceIsFixedWidth()... no checking for TTF_FontFaceFamilyName()... no checking for TTF_FontFaceStyleName()... no checking for SDLSKK_Context_new() in -lSDLSKK... no creating Makefile % sudo make install install -c -p -m 0755 sdl.bundle /usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin7.7.0 install -c -p -m 0644 ./lib/rubysdl_aliases.rb /usr/local/lib/ruby/site_ruby/1.8 install -c -p -m 0644 ./lib/sdl.rb /usr/local/lib/ruby/site_ruby/1.8
patchをあててない場合、
こんなエラーがでます。-no-cpp-precompを加えると直る。
% make gcc -fno-common -g -O2 -fno-common -pipe -fno-common -I/usr/local/include/SDL -D_THREAD_SAFE -D DEF_EVENT2 -D DEF_OPENGL -I. -I/usr/local/lib/ruby/1.8/powerpc-darwin6.8 -I/usr/local/lib/ruby/1.8/powerpc-darwin6.8 -I. -I/usr/X11R6/include -c rubysdl_cdrom.c cpp-precomp: could not open 'DEF_EVENT2' <built-in>:1:1: no macro name given in #define directive make: *** [rubysdl_cdrom.o] Error 1
■rsdl install
% wget http://www.kumaryu.net/cgi-bin/diary/files/rsdl.tar.gz % tax rsdl.tar.gz gzip: stdin: unexpected end of file tar: Child returned status 1 tar: Error exit delayed from previous errors →エラーが出るが、気にしない。 % cd rsdl % ruby -v ruby 1.8.2 (2004-12-25) [powerpc-darwin7.7.0] →先程installしたrubyであることを確認。 % ruby configure.rb; make % ./rsdl -v ruby 1.8.2 (2004-12-25) [powerpc-darwin7.7.0]
よっしゃ。完成。
% sudo cp rsdl /usr/local/bin % rehash
これでrsdlがinstallできた.
■rsdlの動作確認
% cd ../rubysdl-0.9.4/sample % ruby testgl.rb objc: failed objc_getClass(NSObject) for SDL_QuartzWindow->isa->isa objc: please link appropriate classes in your program Trace/BPT trap
このように,通常のrubyだとうまく動かない.
% rsdl testgl.rb ## Component Manager: attempting to find symbols in a component alias of type (regR/carP/x!bt)
その代りにrsdlを使うとうまく動くようになる.OK!
Last modified: 2006-09-05