Build MacTacular

One of the software projects I have been working on over the summer required the software to be built for MacOS X, but not just any old version - it had to be built for MacOS X 10.3.9, and it had to run on the PowerPC.

This was an interesting challenge. Especially since I didn’t have a Mac!

I knew that Apple provides some cross-compilation capabilities with their Mac development tools, especially since they just changed from PowerPC to Intel processors only a little while ago, and they want to keep their developers from completely revolting. So I got on the Apple developer site and looked around for what my options were, and once I verified that I could do what was needed, I went and bought a Mac mini from the local Apple Store. Of course, reading that it can be done, and then figuring out how to do it, sometimes there’s a bit of a gap between the two.

It’s also been a long time since I built any software on the Mac, over two years now. As I was working through this project, all these little details were coming back to me - how to manage dynamic libraries on the Mac, how to get things to statically link instead of dynamically linking, all these fun little details. But there was the additional wrinkle of having to cross-compile to a different architecture, and to support a different operating system version, and those added an extra layer of difficulty to the problem.

Most of the Apple developer site documentation about cross-compilation is aimed at using the Xcode IDE to do the building. Unfortunately, there are quite a few projects out there that already use autoconf, make, etc. to implement their build process, and there just isn’t a lot of documentation about how to cross-compile with autoconf projects. But fortunately I was able to figure it out from the man pages and a few other information sources. Thankfully there weren’t too many nasty roadblocks along the way.

MacOS X provides a very nice, useful development feature: It actually includes the header files and libraries from previous versions of the operating system, so that you can build and link software to run against earlier versions of the OS. I think this is just fantastic; without that, it simply wouldn’t have been possible to do what I needed to do. All you have to do is give the compiler an argument specifying the minimum OS version to support, and it does the rest.

Then there is the other challenge - how to compile a program for the PowerPC processor, using a Mac with an Intel processor. Again, Apple really comes through for its developers by providing specialized compilers for building to the PPC architecture. In addition, the system libraries include both PowerPC and Intel versions, so everything comes together pretty seamlessly once you figure out how to make everything go.

The only other issue I ran into with this project was that the main application depended on three other libraries, and if you are going to build an application to run on PowerPC, all the dependencies have to be built for the PowerPC too. So that required a bit of figuring out to get it all nailed down. But once all the dependencies were built for the PPC processor, and once I had the app building against these libraries, it all just worked.

I think I am going to have to write up a document about how to do this, and put it in my Programming Notes. There just isn’t a lot of documentation about how to do this, and I think it could be really helpful for people who find themselves in the same situation I did.

Plus, I don’t ever want to have to figure all that stuff out again!

Leave a Reply