Qt for Mac OS X

Mac OS X is a UNIX platform and behaves similarly to other Unix-like platforms. The main difference is that X11 is not used as the windowing system. Instead, Mac OS X uses its own native windowing system that is accessible through the Cocoa API. Application development on Mac OS X is done using Xcode, which is available from https://developer.apple.com/xcode/.

After installing Xcode you need to download the command line tools. This is done in the Preferences dialog under the Downloads section. After installing, the Clang compiler should be available from the command line.

Downloading and Installing Qt

You can download Qt 5 installer from http://qt-project.org/downloads. The download page contains the installer and the source packages for all supported development platforms. Once downloaded, the installation program runs like any executable on Mac OS X. With the installer, you can select the components you want.

Note: Qt Enterprise packages are available from the Try Qt Enterprise page.

The Qt Installation Program page contains the full installation procedure and the available installers.

Building Qt 5 from Source

You can also build Qt 5 from the source package and configure it according to your target platform. The source packages are obtained from http://qt-project.org/downloads.

Below, you will find more information about building Qt from source.

Note: Qt 5 uses Cocoa, therefore, building for Carbon is not possible.

Mac OS X Versions

Mac OS X 10.7 "Lion" and 10.8 "Mountain Lion" are considered reference configurations, meaning they are tested by a continuous integration (CI) system. Qt 5 applications may be deployed to Mac OS X versions 10.6 "Snow Leopard", but support is limited.

Qt can be built for either x86 or x86_64. 64-bit is used by default. To select a 32-bit build, use the macx-clang-32 or macx-g++32 mkspec. This is selectable at configure time:

./configure -platform macx-clang-32

The Qt build system does not support building unversal binaries directly. Instead, use the lipo tool to glue two Qt builds together.

Note: Qt 5 does not support Mac OS X on PowerPC.

Note: Static builds are not tested.

Additional Command-Line Options

On the command-line, applications can be built using qmake and make. Optionally, qmake can generate project files for Xcode with -spec macx-xcode. If you are using the binary package, qmake generates Xcode projects by default; use -spec macx-gcc to generate makefiles. For example:

qmake -spec macx-xcode project.pro

Configuring with -spec macx-xcode generates an Xcode project file from project.pro. With qmake you do not have to worry about rules for Qt's preprocessors (moc and uic) since qmake automatically handles them and ensures that everything necessary is linked into your application.

Qt does not entirely interact with the development environment (for example plugins to set a file to "mocable" from within the Xcode user interface).

The result of the build process is an application bundle, which is a directory structure that contains the actual application executable. The application can be launched by double-clicking it in Finder, or by referring directly to its executable from the command line, for example, myApp.app/Contents/MacOS/myApp.

If you wish to have a command-line tool that does not use the GUI for example, moc, uic or ls, you can tell qmake to disable bundle creation from the CONFIG variable in the project file:

CONFIG -= app_bundle

Deploying Applications on Mac OS X

In general, Qt supports building on one Mac OS X version and deploying to earlier or later Mac OS X versions. You can build on 10.7 Lion and run the same binary on 10.6. The recommended way is to build on the latest version and deploy to an earlier Mac OS X version.

Mac OS X applications are typically deployed as self-contained application bundles. The application bundle contains the application executable as well as dependencies such as the Qt libraries, plugins, translations and other resources you may need. Third party libraries like Qt are normally not installed system-wide; each application provides its own copy.

A common way to distribute applications is to provide a compressed disk image (.dmg file) that the user can mount in Finder. The deployment tool, macdeployqt (available from the Mac OS X installers), can be used to create the self-contained bundles, and optionally also create a .dmg archive. Applications can also be distributed through the Mac App store. Qt 5 aims to stay within the app store sandbox rules. macdeployqt (bin/macdeployqt) can be used as a starting point for app store deployment.

Mac OS X Issues

The page below covers specific issues and recommendations for creating Mac OS X applications.

Where to Go from Here

We invite you to explore the rest of Qt. We prepared overviews to help you decide which APIs to use and our examples demonstrate how to use our API.

Qt's vibrant and active community site, http://qt-project.org houses a wiki, a forum, and additional learning guides and presentations.