Monday, September 04, 2006

Semi-Universal Binaries

I ran into an issue a few months back when trying to get an OSX app to run on the new MacTel boxes. Although XCode now comes with the ability to construct universal binaries from the same source code, there are still issues when you link in 3rd party libaries. This was my problem. My application used Berkeley DB, and although the souce is available (I used to to build the static libarary I linked to on the powerpc version of my software) I wasn't sure how a Universal Binary version of this library would work. I didn't want to take the chance on breaking my existing version of the software to accomodate the Universal Binary version. So, my solution was to build two separate versions and use a bootstrapper application to launch the appropriate one. Essentially, I have a powerpc version of my app that links in the powerpc version of BerkelyDB and an intel version that links in the intel version of BerkeleyDB. Each version is loaded into the Resources directory of the bootstrapper application. When the bootstrapper (which is a Universal Binary) launches, it simply detects the architecture that it's running on an then launches the appropriate version of the application. This approach is a little awkward, I know, but it has the advantage of letting you keep using the code that you know works while at the same time supporting a new platform.

No comments: