Saturday, January 19, 2008

Installing Fox and FXRuby on Mac OS X Leopard (Intel)

I'm planning to start playing with some of the GUI toolkits available for Ruby, and I know there's a Pragmatic Programmers book (currently in beta) for FXRuby, so I thought I'd get the fixin's in place to be able to play with it. Unfortunately, the standard sudo gem install fxruby alone didn't get the job done for me. Even using MacPorts to install Fox first (sudo port install fox) let me down. Here's what (eventually) did work:

  • Download and Install Fox:

    • Download the source. I picked the current stable version from the "Downloads" section, "Linux/Unix" subsection.

    • Set the LDFLAGS environment variable as described in Lyle Johnson's (author of FXRuby and the book) very helpful post:
      export LDFLAGS="-dylib_file \
      /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:\
      /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"
      Note: There's a typo in Lyle's instructions that will trip you up if you just cut and paste from there; there should be a space between the "-dylib_file" and the first "/System/Library/...". And, in case you're cutting and pasting from here, there should be no space between the colon and the second "/System/Library/...".

    • cd to the expanded Fox source folder.

    • ./configure, with whatever options you would normally use. I didn't specify anything in particular.

    • sudo make install, again with your typical options. The vanilla command worked for me.



  • Install the FXRuby gem:

    • sudo env ARCHFLAGS="-arch i386" gem install fxruby

    • The extra bits about the ARCHFLAGS are a workaround for a problem in ld (and/or lipo) trying to build this gem for both PPC and Intel architectures. As you might guess, this will work for you only if you're on an Intel Mac.

    • From the Credit-Where-Credit-Is-Due department: I cribbed the "env ARCHFLAGS" trick from the most excellent Hivelogic website, specifically this post.



  • Write a cool GUI! (Haven't gotten that far on this item yet...)


Oh, and I'll be looking at Shoes too. No weird Unix/Linux project dependencies for that one, thank goodness. Just a regular .dmg to download and install. Nice.

2 comments:

Unknown said...

so how are your GUI adventures in Ruby-land coming? Any success packaging FXRuby apps for cross-platform deployment?

David Rupp said...

Hi, Jon. Thanks for checking in. Sadly, my "GUI adventures in Ruby-land" are non-existent right now. I've been a very bad Rubyist; too much going on at work (Java-based) right now. Lyle's book is still on my radar, though.