Category Archives: Mac OS

GLFW – Compiling Source and Creating an Xcode Project

GLFW is a great library – easy to use, great documentation covering it’s API design. But if you’re not on Windows where they provide pre-built libraries, going from a source download to a compiling Xcode project is _not_easy.

Since brew (as of writing) only provides GLFW 2, you need to build GLFW 3 yourself.

There is barely any information on it at all, it assumes you know exactly what you’ve downloaded (the source and some CMake files btw) and that you’ll be able to figure it all out (there is some additional information if you root around the GitHub forums but it’s not exactly easy to find).

So I’m posting up how I got GLFW to compile and running in Xcode here in-case anyone else starts banging their head against a brick wall.

First off, download the source followed by Cmake (I downloaded the 64/32-bit .dmg for

Now to get it to compile you need to set up a few options. You can do this in the Cmake GUI, but I found it much easier to do it manually. Browse to GLFW/Src and open

This is a settings file for the compile you’re about to perform. There are a lot of settings in here you can play around with (they are explained in the file in the root GLFW folder), but I enabled the following

  • _GLFW_NO_DLOAD_WINMM (this is a Windows only define, but I enabled it so adding it here anyway)


Save the file and then you’re ready to compile.

Open the Terminal and browse to the root of the GLFW folder and enter the following commands

cmake .
make install

The Cmake command will set up the project ready to be built. It’ll take the config file we modified earlier and create a valid config.h file and it’ll carry out any other set up needed as well. ¬†Calling make builds the project, the install command installs the library in it’s default location.

Now you’re ready to add GLFW to your Xcode project. To keep it simple I’ll step through adding it to a new project, once you can do that adding it to an existing one is pretty easy.

  • Open Xcode and create a new OSX Command Line Tool project
  • In the project settings add the path to the GLFW include file in the ‘Header Search Paths’ and the path to the libglfw3.a lib to the ‘Library Search Paths’ option (both of these paths are shown in the install make output)
  • Add libglfw3.a to the Link build phase
  • You also need to add the following Frameworks to the build phase to allow the project to compile
    • IOKit
    • Cocoa
    • OpenGL


You can now copy/paste the sample code provided on the GLFW website into the existing main.c file, hit compile and you have a running GLFW project.

Note that the sample code doesn’t call glclear before glfwSwapBuffers so what you get in the open window is undefined.

Ruby, Jenkins and Mac OS

I’ve been using Jenkins as my CI server for a while and though user permissions has always been a bit of an issue (I’ll explain why in another blog post covering my Unity build process) running command line tools has never been to much of a problem once it got going.

At least not until I tried to run Ruby 1.9.3 via RVM on our Mac Jenkins server.

I’d developed the Ruby scripts outside Jenkins so I knew they worked, but when I came to run them through Jenkins (using nothing more than the ‘Execute Shell’ build step) it started behaving strangely. Running the script caused the step to fail instantly claiming it couldn’t find any of my installed Gems.

A quick ‘gem query –local’ on the command line listed all the gems I needed were there.

As an experiment I added a build step that installed the Trollop gem (a fantastic gem, you should check it out!) to see if that made any difference, in effect forcing the install in the service that would run the Ruby script. I was surprised when the install worked, but it installed it for Ruby 1.8 rather than Ruby 1.9.

Adding ‘ruby –version’ as a build step showed that for some reason the Jenkins server was using Ruby 1.8.7 rather than 1.9.3.

It turns out that RVM is not available when run through a non-interactive shell script, which is a bit inconvenient when you need it run as part of an automated process.

Searching around I came across this Stack Overflow answer suggesting I make changes to my .bash_profile but those changes were already present meaning I had little luck in finding a solution.

Other suggestions involved rather convoluted steps to just get the thing working, something I neither had the time for nor thought should be required.

Luckily Jenkins provides a RVM Plugin which allows the build step to run inside an RVM managed environment meaning it will respect the RVM settings I’ve set outside of Jenkins…

Now when running ‘rvm list’ via a build script shows that we have multiple versions of Ruby available with 1.9.3 set as the default.

And all of a sudden my Ruby scripts work like a charm!

Bug or Bad UI: Find and Replace in XCode 4

As applications get larger and more complicated with every iteration it sometimes becomes difficult to know if incorrect behaviour is down to a bug or badly designed user interface. XCode 4 is an application that has some quirky design choices, some which I really like and some which just baffle.

Here’s one a I found recently when trying something as simple as ‘Find and Replace’

Go to the search tab and search for something (preferably something that exists!). So in the following screenshot I’m searching for ‘defgroup’ which is a Doxygen documentation tab.

Now switch over to ‘Find’ and, as you would do if you did this a while later, change what you last searched for to what you want to replace. In this example, I’m now looking to change ‘client’ to ‘user’. Looking at the following screenshot, what would you expect to be replaced?

In my mind, I expected ‘client’ to be replaced with ‘user’. After all, that’s what I’ve put next to the Magnifying Glass icon – a universal icon for ‘search’ – and the results are for the last search I did, not this one.

But if I select Preview…

It’s actually replacing the results of the original search for ‘defgroup’ and not what I actually asked for, which was to replace ‘client’ with ‘user’. If I’d gone and selected Replace All then the same thing would have happened.

To get it to replace ‘client’ rather than ‘defgroup’ I need to either

  • Go back to Find search for ‘client’ then switch back to Replace and do it again
  • When entering the new search term, hit enter after typing ‘client’. This won’t do the replace, it’ll redo the search.


So, is this a bug or a failure of UI design? Should Preview and Replace All take what I’ve just put in the search box (in which case it’s a bug) or should it use what I last searched for (in which case it’s a UI issue).

Personally, I see this as a bug. As I work down the panel, I add what I what to replace with the new term then select Replace All. Since we read from left to right and top to bottom, information at the top of the screen is more important (the new term) than at the bottom (the results of the last search).

But then, some people could argue it’s a UI issue, and in that case an improvement to this work-flow from a UI perspective would cause this bug to never appear in the first place.

Macintosh Hackintosh

I recently bought a Mac. I wanted a small, easy to use media centre to sit next to my TV and while I originally looked into getting a Dell Zino I thought it’d be a perfect time to get an unintrusive Mac and headed off to the Apple Store and picked up a Mac Mini.

So far I’m loving it (even after having to return the first Mini due to a faulty graphics card and then the wireless keyboard due to a faulty space bar!) and as an introduction to Mac’s it’s been worth it. I don’t really do anything ‘Maccy’ on it other than use XBMC,¬†browse the internet and use Aperture but I’m actually enjoying the experience rather than wanting to throw the machine out of the window (having said that, I’ll still dual boot to Windows should I want to do any hobby development with XNA).

Since I was so impressed with it, I thought it’d be worth trying to install Mac OS X on my little Dell Mini 9. I love my Mini 9 but even with a fresh install it’s been struggling even running Windows XP (taking 10 minutes to boot up(!), constantly freezing and generally being pretty naff). Installing OS X, I hoped, might give it a bit of a kick up the backside.

I also network the two machines, using the Dell as a little media server and Time Machine seemed to meet my server back up needs and it’s free out of the box. What’s not to like?

I was worried that this would involve kernel hacking, boot strap loaders, luck and quite a bit of swearing but surprisingly it was stupidly easy… Following the Hackintosh instructions for the Dell Mini 10 resulted in a Mac powered Mini 9 in about 90 minutes.

But then things got a little bit complicated. Anyone keeping track of the Hackintosh ‘scene’ will know that OS X 10.6.2 dropped support for Atom processors, put it back in, then dropped it in the final release, which would mean no OS X on my Dell Mini. But not updating an OS isn’t really that good an idea.

A few quick hits on Google brought up a possible hack. Changing various kernel files, kernel panics (seriously I’d panic trying this) and any other number of things that can go wrong (I’m not worried about anything breaking because it’s not going to be the end of the world. I just don’t really have the time to try and figure out what I need to do and do it, rather than it just working out of the box).

But there really are some cool people on the internet. Using NetBook Installer (a sister project to the Netbook BootMaker tool which was used to install OS X in the first place).

Updating from OS X 10.6.0 to 10.6.2 was as simple as

(I probably didn’t need to run Netbook Installer the first time but it only take 5 minutes).

And literally that was is. A smooth copy of OS X 10.6.2 running on my compact Dell Mini 9 as a quiet, low power media server.

It’s all good.

(It might be noticed that I’ve not been blogging much recently. I’ve not run out of things to say it’s just that with moving house, Christmas and lots (and lots) of DIY, the time has just not been there. Service will resume at some point – soon)