Saturday, January 19, 2008

Fox/FXRuby/Leopard, Part the Second

As a follow-on to my previous post, I discovered that there's a little more work to be done to actually be able to use my freshly installed FXRuby. I tried using the listexample.rb program from the aforementioned Pragmatic Programmers book, and promptly found that the 'fox16' library couldn't be required. Grumble.

Fortunately, this post on the fxruby-users mailing list (again, courtesy of Lyle Johnson, lead programmer of FXRuby and author of the PragBook) was able to get me going:
a workaround is to use the "gem env" command to identify your Gems installation directory (usually something like /usr/local/lib/ruby/gems/1.8) and switch to the "gems/fxruby-[version]/ext/fox16" directory underneath that:
cd /usr/local/lib/ruby/gems/1.8/gems/fxruby-1.6.0/ext/fox16
and then type:
make
Note: Since RubyGems comes installed with Leopard, your gem installation directory is more likely to be something like "/Library/Ruby/Gems/1.8", at least if you did a fresh install as I did. YMMV.

But here I encountered the same architecture problem I referenced in my previous post. This time I ended up editing the Makefile and deleting all references to "-arch ppc"; setting the ARCHFLAGS environment variable before running make didn't cut it for me.

Once you've re-made the gem, you should be able to verify your installation in irb:
>> require 'fox16'
=> true
Two final caveats:
  • I had to modify the PragExample with the line "require 'rubygems'" at the top of the file, right before the "require 'fox16'" line. This was because I haven't yet set my RUBYOPT environment variable in Leopard to require rubygems automatically for me.
  • The example program worked fine for me after all this (try holding the shift button to do multiple selections), until I quit, at which point I got:
    X Fatal Error.
    Abort trap
So this FXRuby thing is not an exact science yet. Sigh.

2 comments:

Lyle said...

David, thanks for blogging about your experiences in trying to get this working on Leopard. I personally have been holding off on upgrading to Leopard until SuperDuper! (my backup tool of choice) is working there, so I haven't had much opportunity to investigate the issues on Leopard yet. As always, please post questions to the fxruby-users list, or the bug tracker, if you run into trouble!

David Rupp said...

Thanks, Lyle. It was your post about defining LDFLAGS that pointed the way. I'm looking forward to the book, now that I've got the infrastructure in place. :-)