Universal binaries with Qt 4.1.x

OK, many people are starting to wonder about Mac OS X universal binaries. The good news is that you can start playing with universal binaries already with the release candidate for Qt 4.1.0. Here's the steps, assuming you are on a PPC machine.

configure Qt with these extra flags:

-universal -sdk /path/to/MacOSX10.4u.sdk

After which you can simply build Qt normally. BUT, If you are one of those people who have upgraded to Xcode 2.2, you will have to edit QTDIR/mkspecs/features/mac/sdk.prl to make it look a little more like this:

!isEmpty(QMAKE_MAC_SDK) {
QMAKE_LFLAGS += -Wl,-syslibroot,$$QMAKE_MAC_SDK

This will be fixed for the final Qt 4.1.0 release.

After which, if you want to build your own program as a universal binary add this to your .pro file

CONFIG+=x86 ppc

Afterwards, run 'file' on your binary and you should see that you have a PPC and x86 binary.

Congratulations, you just doubled the size of your binary :)

Blog Topics: