Sunday, January 17, 2010

installing rsdl on OS X i386 via rubygems

I was getting this problem trying to install rsdl, a wrapper program for ruby which initialises SDL/Cocoa:

Jehannum:SDL-1.2.14 oisin$ sudo gem install rsdl
Building native extensions. This could take a while...
ERROR: Error installing rsdl:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for ruby_sysinit()... no
checking for ruby_run_node()... no
creating Makefile
creating rsdl.c

make
gcc -arch ppc -arch i386 -Os -pipe -fno-common -I"/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0" -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE -c rsdl.c
gcc rsdl.o -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L. -arch ppc -arch i386 -lruby -lpthread -ldl -lm -L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa -o rsdl
ld: warning in /usr/local/lib/libSDLmain.a, file is not of required architecture
ld: warning in /usr/local/lib/libSDL.dylib, file is not of required architecture
Undefined symbols for architecture ppc:
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found for architecture ppc
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//ccEkUyfQ.out (No such file or directory)
make: *** [rsdl] Error 1


The solution was to add an ARCHFLAGS environment variable which stops it trying to build a ppc version:
Jehannum:SDL-1.2.14 oisin$ sudo env ARCHFLAGS='-arch i386' gem install rsdl
Building native extensions. This could take a while...
Successfully installed rsdl-0.1.2
1 gem installed
Installing ri documentation for rsdl-0.1.2...
File not found: lib

The "File not found" message at the end doesn't seem to matter.

It's handy that SDL, SDL_image and SDL_gfx seem to build and install the UNIX way (./configure && make && sudo make install) with no problems - at first I was worried by the lack of a .pkg installer for SDL but it seems to work fine so far. Cool!

1 comment:

  1. Thanks for the tip, for me I had to request 64bit:

    env ARCHFLAGS='-arch x86_64' gem install rsdl

    ReplyDelete