Archive for January, 2008

Building FXRuby on Leopard with MacPorts

A number of people are having interesting problems trying to build FXRuby on Leopard (Mac OS 10.5) and so I’m trying to pin down exactly where the problems are. Last month, I wrote about some of the fundamental problems that you might run into building FXRuby “from scratch”, without the help of MacPorts. One problem has to do with an apparent bug in the latest release of the Xcode Developer Tools, and another has to do with the buggy X11 server that ships with Leopard. Putting those issues aside, I thought that the MacPorts build was working fine.

Turns out it wasn’t fine after all. Sorry about that.

In an attempt to get to the bottom of things, I began by completely wiping out the /opt directory on my iMac (which is running Mac OS 10.5.1). Next, I reinstalled the MacPorts 1.6.0 base package. Finally, I fired off an install of the rb-fxruby port:

$ sudo port -v install rb-fxruby
Then I went to bed, because I knew that this fresh install of MacPorts was going to need to download and build a bunch of dependencies before it ever got anywhere near FXRuby.

When I checked on the progress the next morning, I saw that, sure enough, the build failed for FXRuby. Some of the last gasps of that attempted build included lines like:

i686-apple-darwin9-gcc-4.0.1: corewrap.o: No such file or directory i686-apple-darwin9-gcc-4.0.1: dcwrap.o: No such file or directory i686-apple-darwin9-gcc-4.0.1: dialogswrap.o: No such file or directory
which suggests that those object files were either never compiled, or that they were compiled and subsequently blown away before the linker could get to them. Turns out it was the former case. When I scrolled a little further up in the build log, I could see lines like:
I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.1.0 -I/opt/local/var/macports/build/optlocalvarmacportssourcesrsync.macports.orgreleaseportsrubyrb-fxruby/work/FXRuby-1.6.13/ext/fox16 -DHAVESYSTIMEH -DHAVESIGNALH -I/opt/local/include/fxscintilla -I/opt/local/include/fox-1.6 -I/opt/local/include -fno-common -O2 -fno-common -pipe -fno-common -O0 -Iinclude -DWITHFXSCINTILLA -DHAVEFOX16 -c corewrap.cpp make: I.: Command not found make: [corewrap.o] Error 127 (ignored)
If you’re not used to scouring build logs looking for strange errors, it may not be obvious what’s wrong: there ought to be a compiler command (such as gcc or g++) at the beginning of the line that starts out “I. -I. -I/opt/local/...“.

What’s even more interesting to me is that when I typed (again):

$ sudo port -v install rb-fxruby
This time, the build went through fine. Those lines that previously didn’t show a compiler command were now invoking the C++ compiler (g++), and so those object files (like core_wrap.o) that were missing in action the last time around got created after all, and everyone lived happily ever after.

So the next part of the investigation is for me to figure out what was broken during the first pass, and why the C++ compiler wasn’t being picked up properly by FXRuby’s extconf.rb script. More to come…

Update: Problem seems to be resolved as of the latest update to Ruby in MacPorts.

Second Beta Release for FXRuby Book

An updated version of the beta book has been released today. The most visible change for this release is the inclusion of the final three chapters of the book, which were still being edited and revised at the time of the initial release. The new chapters cover layout managers, menus and toolbars, and dialog boxes. Thanks to comments and suggestions from beta book readers and other reviewers, I’ve had the opportunity to make a number of fixes and improvements to the previously released chapters as well.

Many of the changes involved the extended “Picture Book” tutorial. For example, the layout algorithm that was described in section 4.4 didn’t work well in some circumstances (e.g. when the first photo in the album was taller than it was wide, or when the main window was resized so that it was narrower than the width of the first photo). As a result of these and other issues, that section has been revised a bit. Another significant problem that several readers noted had to do with the initialize() method for the AlbumView class, which mysteriously changed between chapters 4 and 5 without any explanation. This problem has also been corrected.

Some readers have been having trouble running the examples due to misconfigured RubyGems installations. The code in the book is written under the assumption that if you’ve installed FXRuby using RubyGems, that you’ve also configured Ruby to automatically load up the runtime support for RubyGems, so that require statements will search through your installed gems repository when it’s trying to find libraries like FXRuby. As a result of the confusion over this issue, I’ve added a new sidebar that discusses RubyGems configuration issues.

Finally, there were a handful of other little changes, in some cases fixing typos, in other cases clarifying and improving the original text. When you work on a project like this for months at a time, it’s difficult to be objective about it and see things as clearly as fresh sets of eyes can. Thanks to all of the readers who have taken the time to add a report to the official errata list, or to make a post to the book’s forums, or to fire off an e-mail to me. Many of your suggestions have already been incorporated, and I’m keeping track of all of them as I evaluate which changes to make in subsequent releases.

FXRuby Book Now Available as Beta Release!

I’m pleased to report that FXRuby: Create Lean and Mean GUIs with Ruby has been released as a Beta book. That means that although the book is still under development, you can get early access to the content right now and provide feedback to help make the final book even better when it’s released later this year. We’re getting very close to a completed first draft and I can assure you that it’s well worth it to go ahead and get the book now if you’re anxious to get started with FXRuby programming.

As I’ve noted before, this is the first book ever dedicated to the subject of FOX and FXRuby application development. It’s intended for software developers who are already comfortable with Ruby programming and who want to learn how to develop GUI applications with Ruby. No prior experience with GUI development is needed, but it’s intended to be useful both to newcomers as well as those who have worked with other GUI toolkits in the past.

The purpose of this book is to give you a head start on developing GUI applications with Ruby and FXRuby through a combination of tutorial exercises and focused technical information. It isn’t a comprehensive book on FXRuby programming, and it’s not a reference manual. What this book will do is get you over the initial conceptual hurdles and equip you with the practical information that you need to build your own applications. Surf on over to the Pragmatic Bookshelf site and order your copy today!

New Year’s Goals

I’m not going to call them resolutions, because that implies a bit too much of a commitment, but I’ve been thinking about some of the techie goals that I have for this year.

First, the obvious one. My goal (and my publisher’s “goal”, if you want to call it that) is to get the book finished. And we’re well on our way to accomplishing that.

Next, I want to learn a new programming language this year. Although I’m taking a look at Scala, I received Programming Erlang for Christmas (because my wife is just that good) and I’m liking what I’ve read about Erlang so far. I have the feeling that it’s going to win out. Scala reminds me a little too much of Java.

Lastly, I want to learn a lot more about developing applications for Mac OS X. That will no doubt involve my learning some Objective C along the way, but that’s not a bad thing. I’m especially eager to dig into the RubyCocoa framework that shipped with Leopard, to see how viable a platform that is for developing and shipping commercial Mac OS X applications.

What about you? What are some of the technologies that you think you’ll be checking out in 2008?

Would you like to be a reviewer?

Some of you may know that I’m writing a book about FXRuby for the Pragmatic Bookshelf. I’m almost finished with the first draft, and I’m looking for some volunteers to review the book. Specifically, I’m looking for people to go over the book with a fine toothed comb, looking for inconsistencies, things that are confusing or misleading, and outright errors. When there are example programs, I’d like for you to try to run the programs and make sure they work the way the book claims that they work. That sort of thing. Depending on how fast you can read and absorb the material, and then provide feedback based on what you’ve seen, a thorough review might take a few hours or a few days.

In a nutshell, the book is aimed at folks who do know Ruby but who don’t necessarily know anything about FOX/FXRuby or GUI programming in general. That’s the target audience for the book. It’s not a comprehensive book about all things FOX and FXRuby, and a lot of the more advanced topics are intentionally left out. The idea is that after reading this book, you’ll have enough of a foundation to tackle some of those more advanced topics on your own.

If you’re interested in being a reviewer, and (more importantly) if you believe that you have the time to do this, please respond in the comments, or contact me as soon as possible. We’re looking to release it as a beta book as soon as next week, and we’d be getting the completed first draft out to reviewers shortly after that.

Update: Well, that went fast! Looks like I now have plenty of reviewers lined up. Stay tuned for further announcements about the beta book release!