Contents
Ruby/SDL on Windows
Ruby/SDLをWindows上で動かす。コンパイルして使う方法について述べる。 Ruby/SDL binaryでは、バイナリで使う方法について述べている。
■Cygwinの準備
- Cygwinにおいて,gccが必要.gccでコンパイルができなければ、Cygwinのsetup.exeを起動し、gccを追加しておく必要がある。
- →All→Devel→gcc
■SDL
- http://www.libsdl.org/
- http://www.libsdl.org/download-1.2.php
- http://www.libsdl.org/release/SDL-1.2.9.tar.gz
- http://www.libsdl.org/release/SDL-1.2.9-win32.zip
% wget http://www.libsdl.org/release/SDL-1.2.9.tar.gz % tar xf SDL-1.2.9.tar.gz % cd SDL-1.2.9 % ./configure; make; make install % cd test % ./configure; make; ./testgl →OpenGLが使えることを確認
全部自動的に -mno-cygwin でcompileする設定となるので、特にconfigureにオプションを指定する必要はない。
■Ruby 1.8.2 MinGW版 install
- http://www.ruby-lang.org/ja/
- http://www.ruby-lang.org/ja/20020102.html
- ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.4-preview2.tar.gz
% wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.4-preview2.tar.gz % tar xf ruby-1.8.4-preview2.tar.gz % cd ruby-1.8.4 % ./configure --with-gcc='gcc -mno-cygwin' CFLAGS=-O2; make; make test; make install
■get glut header
- http://www.opengl.org/resources/libraries/glut/
- http://www.opengl.org/resources/libraries/glut/glut-3.7.tar.gz
- http://www.opengl.org/resources/libraries/glut/glut37.zip
% wget http://www.opengl.org/resources/libraries/glut/glut-3.7.tar.gz % tax glut-3.7.tar.gz
■Ruby/OpenGL install
% wget http://www2.giganet.net/~yoshi/rbogl-0.32f.tar.gz % tax rbogl-0.32f.tar.gz % cd opengl-0.32f ←変則的 % mv ../glut-3.7/include/GL . →GLUTのheaderだけもってくる.
下記のpatchをあてる.
--- ./extconf.rb.org 2005-05-22 19:30:14.062500000 +0900 +++ ./extconf.rb 2005-05-22 19:31:27.656250000 +0900 @@ -23,0 +24 @@ +when /mingw32/
% ruby extconf.rb; make; make install install -c -p -m 0755 opengl.so c:/usr/local/lib/ruby/site_ruby/1.8/i386-msvcrt install -c -p -m 0755 glut.so c:/usr/local/lib/ruby/site_ruby/1.8/i386-msvcrt
なんでglutも認識されちゃうんだろうな….
■Ruby/Math3D install
% wget http://www2.giganet.net/~yoshi/math3d-0.04.tar.gz % tax math3d-0.04.tar.gz % cd math3d-0.04
patchをあてる.
--- ./extconf.rb.org 2005-05-22 19:39:26.375000000 +0900 +++ ./extconf.rb 2005-05-22 19:40:43.875000000 +0900 @@ -7,0 +8 @@ +CFLAGS = [] --- ./math3d_native.c.org 2005-05-22 19:42:59.406250000 +0900 +++ ./math3d_native.c 2005-05-22 19:44:57.515625000 +0900 @@ -1187 +1187 @@ - case NEAR: + case NNEAR: @@ -1193 +1193 @@ - case FAR: + case FFAR: @@ -1341,2 +1341,2 @@ - m3d_plane_new_points(&result->plane[FAR], &result->corner[FAR_HR], &result->corner[FAR_LR], &result->corner[FAR_LL]); - m3d_plane_new_points(&result->plane[NEAR], &result->corner[NEAR_LL], &result->corner[NEAR_LR], &result->corner[NEAR_HR]); + m3d_plane_new_points(&result->plane[FFAR], &result->corner[FAR_HR], &result->corner[FAR_LR], &result->corner[FAR_LL]); + m3d_plane_new_points(&result->plane[NNEAR], &result->corner[NEAR_LL], &result->corner[NEAR_LR], &result->corner[NEAR_HR]); --- ./math3d_native.h.org 2005-05-22 19:41:29.734375000 +0900 +++ ./math3d_native.h 2005-05-22 19:43:42.828125000 +0900 @@ -72,2 +72,2 @@ - FAR, - NEAR, + FFAR, + NNEAR,
% ruby extconf.rb; make; make install install -c -p -m 0755 math3d.so c:/usr/local/lib/ruby/site_ruby/1.8/i386-msvcrt
patchをあててない場合,エラーがでます。
■Ruby/SDL install
- http://www.kmc.gr.jp/~ohai/rubysdl/
- http://www.kmc.gr.jp/~ohai/rubysdl/rubysdl-1.0.0-win32bin-pack.zip
- http://www.kmc.gr.jp/~ohai/rubysdl/rubysdl-1.0.0-win32bin-ruby18.zip
- http://www.kmc.gr.jp/~ohai/rubysdl/rubysdl-1.0.0.tar.gz
% wget http://www.kmc.gr.jp/~ohai/rubysdl/rubysdl-1.0.0.tar.gz % tar xf rubysdl-1.0.0.tar.gz % cd rubysdl-1.0.0
patchをあてる.
--- ./extconf.rb.org 2005-05-22 19:47:51.078125000 +0900 +++ ./extconf.rb 2005-05-22 19:58:40.656250000 +0900 @@ -5,2 +5,4 @@ -$CFLAGS += ' ' + `#{sdl_config} --cflags`.chomp -$LOCAL_LIBS += ' ' + `#{sdl_config} --libs`.chomp +# $CFLAGS += ' ' + `#{sdl_config} --cflags`.chomp +$CFLAGS = "-I/usr/local/include/SDL -Dmain=SDL_main -I/usr/include/mingw -DWIN3 2 -Uunix -mno-cygwin" +# $LOCAL_LIBS += ' ' + `#{sdl_config} --libs`.chomp +$LOCAL_LIBS = "-L/usr/local/lib -lmingw32 -lSDLmain -lSDL -mwindows -mno-cygwin "
これはすごく乱暴な方法である.コマンドラインから,sdl-config --cflagsなどとした出力を直接入力している.
% 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 checking for glVertex3d() in -lopengl32... no checking for gluGetString() in -lglu32... no creating Makefile
% make install install -c -p -m 0755 sdl.so c:/usr/local/lib/ruby/site_ruby/1.8/i386-msvcrt install -c -p -m 0644 ./lib/rubysdl_aliases.rb c:/usr/local/lib/ruby/site_ruby/1.8 install -c -p -m 0644 ./lib/sdl.rb c:/usr/local/lib/ruby/site_ruby/1.8 % cd sample; ruby testgl.rb
動いた.
■sgl install
Last modified: 2006-09-05