cs240 Chess Project on a Mac

Author: Jeff Anderson

So, I use osx on my laptop. It's unix. My cs240 class at BYU uses Linux for all its projects. I've already done all of my projects in such a way that it works fine on mac and linux. The biggest issue is at compile time. The compiler needs a different include path, or the LD_PATH needs to be set differently. This isn't an issue for the autotools project I did, but when writing Makefiles by hand, I had to set paths appropriately.

I'm starting the second large project for cs240, in which I will implement the rules of chess on top of a gtkmm/glade GUI that is provided. I want to make it work on my mac. This shouldn't be difficult, but here's what I did to make it work.

I untarred the example project provided by the TAs. I ran make, and it failed– something to do with needing gtkmm.

So first up is gtk-mm 2.4 and associated development files (headers, etc…). I use fink. fink install gtkmm-2.4 did the trick. It pulled in the development package, and all the required support libraries.

The next thing that failed was libglademm. Same deal here, just do a fink install libglademm2.4

After that, all the object files seem to build without even a warning. When it went to compile the executable, ld complained about lib/libcs240.a: archive has no table of contents. I just switched the command from a s $(LIBRARY) $(LIB_OBJ_FILES) to a -sr $(LIBRARY) $(LIB_OBJ_FILES), and it compiled and launched the GUI. It will need Xorg to be installed. I'm using the apple Xorg 2.3.1. launchd will start it automatically when needed, which makes it convenient for when I'll be doing this program.

It wasn't tremendously difficult, but I figured it may end up being useful to post what I did. I'm kind of curious to see how difficult it would be to port the cs240 chess program to windows using the windows gtk libraries.

update: When I originally did this, I was happy to see a GTK window with a chess board on my screen. The images hadn't loaded, so I figured that was just something that I was going to have to implement later. I then noticed that it does in fact load images just fine on Linux. I dug into the TA code, and got to the part where it was failing to load the images. The TA code has a lame catch ( ... ) which will catch any exception, but I can't look at it or print any messages. It was pixbuf from the gdk library that would have been throwing an exception. I poked around the code to find that it throws a GError struct. Unfortunately, the message was blank, so I'm not sure why it doesn't load. If anyone can figure out why, please let me know!

Posted: Nov 11, 2008 | Tags: School

Comments are closed.