| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com)
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the documentation of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com.
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | /*!
|
|---|
| 43 | \page developing-on-mac.html
|
|---|
| 44 | \title Developing Qt Applications on Mac OS X
|
|---|
| 45 | \brief A overview of items to be aware of when developing Qt applications
|
|---|
| 46 | on Mac OS X
|
|---|
| 47 | \ingroup platform-notes
|
|---|
| 48 |
|
|---|
| 49 | \tableofcontents
|
|---|
| 50 |
|
|---|
| 51 | Mac OS X is a UNIX platform and behaves similar to other Unix-like
|
|---|
| 52 | platforms. The main difference is X11 is not used as the primary windowing
|
|---|
| 53 | system. Instead, Mac OS X uses its own native windowing system that is
|
|---|
| 54 | accessible through the Carbon and Cocoa APIs. Application development on
|
|---|
| 55 | Mac OS X is done using Xcode Tools, an optional install included on every
|
|---|
| 56 | Mac with updates available from \l {http://developer.apple.com}{Apple's
|
|---|
| 57 | developer website}. Xcode Tools includes Apple-modified versions of the GCC
|
|---|
| 58 | compiler.
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 | \section1 What Versions of Mac OS X are Supported?
|
|---|
| 62 |
|
|---|
| 63 | As of Qt 4.5, Qt supports Mac OS X versions 10.3 (for \bold{deployment
|
|---|
| 64 | only}, not for development), 10.4 and 10.5. It is usually in the best
|
|---|
| 65 | interest of the developer and user to be running the latest updates to any
|
|---|
| 66 | version. We test internally against Mac OS X 10.3.9 and Mac OS X 10.4.11 as
|
|---|
| 67 | well as the updated release of Mac OS X 10.5.
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 | \section2 Carbon or Cocoa?
|
|---|
| 71 |
|
|---|
| 72 | Historically, Qt has used the Carbon toolkit, which supports 32-bit
|
|---|
| 73 | applications on Mac OS X 10.3 and up. Qt 4.5 adds support for the Cocoa
|
|---|
| 74 | toolkit, which requires 10.5 and provides 64-bit support.
|
|---|
| 75 |
|
|---|
| 76 | This detail is typically not important to Qt application developers. Qt is
|
|---|
| 77 | cross-platform across Carbon and Cocoa, and Qt applications behave
|
|---|
| 78 | the same way when configured for either one. Eventually, the Carbon
|
|---|
| 79 | version will be discontinued. This is something to keep in mind when you
|
|---|
| 80 | consider writing code directly against native APIs.
|
|---|
| 81 |
|
|---|
| 82 | The current binary for Qt is built for Carbon. If you want to choose which
|
|---|
| 83 | framework Qt will use, you must build from scratch. Carbon or Cocoa is
|
|---|
| 84 | chosen when configuring the package for building. The configure process
|
|---|
| 85 | selects Carbon by default, to specify Cocoa use the \c{-cocoa} flag.
|
|---|
| 86 | configure for a 64-bit architecture using one of the \c{-arch} flags (see
|
|---|
| 87 | \l{universal binaries}{Universal Binaries}).
|
|---|
| 88 |
|
|---|
| 89 | Currently, Apple's GCC 4.0.1 is used by default. When building on 10.5,
|
|---|
| 90 | Apple's GCC 4.2 is also available and selectable with the configure flag:
|
|---|
| 91 | \c{-platform macx-g++42}. GCC 3.x will \e not work. Experimental LLVM-GCC
|
|---|
| 92 | support is available by passing in the \c{-platform macx-llvm} flag.
|
|---|
| 93 |
|
|---|
| 94 | The following table summarizes the different versions of Mac OS X and what
|
|---|
| 95 | capabilities are used by Qt.
|
|---|
| 96 |
|
|---|
| 97 | \table
|
|---|
| 98 | \header
|
|---|
| 99 | \o Mac OS X Version
|
|---|
| 100 | \o Cat Name
|
|---|
| 101 | \o Native API Used by Qt
|
|---|
| 102 | \o Bits available to address memory
|
|---|
| 103 | \o CPU Architecture Supported
|
|---|
| 104 | \o Development Platform
|
|---|
| 105 | \row
|
|---|
| 106 | \o 10.3
|
|---|
| 107 | \o Panther
|
|---|
| 108 | \o Carbon
|
|---|
| 109 | \o 32
|
|---|
| 110 | \o PPC
|
|---|
| 111 | \o No
|
|---|
| 112 | \row
|
|---|
| 113 | \o 10.4
|
|---|
| 114 | \o Tiger
|
|---|
| 115 | \o Carbon
|
|---|
| 116 | \o 32
|
|---|
| 117 | \o PPC/Intel
|
|---|
| 118 | \o Yes
|
|---|
| 119 | \row
|
|---|
| 120 | \o 10.5
|
|---|
| 121 | \o Leopard
|
|---|
| 122 | \o Carbon
|
|---|
| 123 | \o 32
|
|---|
| 124 | \o PPC/Intel
|
|---|
| 125 | \o Yes
|
|---|
| 126 | \row
|
|---|
| 127 | \o 10.5
|
|---|
| 128 | \o Leopard
|
|---|
| 129 | \o Cocoa
|
|---|
| 130 | \o 32/64
|
|---|
| 131 | \o PPC/Intel
|
|---|
| 132 | \o Yes
|
|---|
| 133 | \endtable
|
|---|
| 134 |
|
|---|
| 135 | \section2 Which One Should I Use?
|
|---|
| 136 |
|
|---|
| 137 | Carbon and Cocoa both have their advantages and disadvantages. Probably the
|
|---|
| 138 | easiest way to determine is to look at the version of Mac OS X you are
|
|---|
| 139 | targetting. If you are starting a new application and can target 10.5 and
|
|---|
| 140 | up, then please consider Cocoa only. If you have an existing application or
|
|---|
| 141 | need to target earlier versions of the operating system and do not need
|
|---|
| 142 | access to 64-bit or newer Apple technologies, then Carbon is a good fit. If
|
|---|
| 143 | your needs fall in between, you can go with a 64-bit Cocoa and 32-bit
|
|---|
| 144 | Carbon universal application with the appropriate checks in your code to
|
|---|
| 145 | choose the right path based on where you are running the application.
|
|---|
| 146 |
|
|---|
| 147 | \target universal binaries
|
|---|
| 148 | \section1 Universal Binaries
|
|---|
| 149 |
|
|---|
| 150 | In 2006, Apple begin transitioning from PowerPC (PPC) to Intel (x86)
|
|---|
| 151 | systems. Both architectures are supported by Qt. The release of Mac OS X
|
|---|
| 152 | 10.5 in October 2007 added the possibility of writing and deploying 64-bit
|
|---|
| 153 | GUI applications. Qt 4.5 supports both the 32-bit (PPC and x86) and 64-bit
|
|---|
| 154 | (PPC64 and x86-64) versions of PowerPC and Intel-based systems are
|
|---|
| 155 | supported.
|
|---|
| 156 |
|
|---|
| 157 | Universal binaries are used to bundle binaries for more than one
|
|---|
| 158 | architecture into a single package, simplifying deployment and
|
|---|
| 159 | distribution. When running an application the operating system will select
|
|---|
| 160 | the most appropriate architecture. Universal binaries support the following
|
|---|
| 161 | architectures; they can be added to the build at configure time using the
|
|---|
| 162 | \c{-arch} arguments:
|
|---|
| 163 |
|
|---|
| 164 | \table
|
|---|
| 165 | \header
|
|---|
| 166 | \o Architecture
|
|---|
| 167 | \o Flag
|
|---|
| 168 | \row
|
|---|
| 169 | \o Intel, 32-bit
|
|---|
| 170 | \o \c{-arch x86}
|
|---|
| 171 | \row
|
|---|
| 172 | \o Intel, 64-bit
|
|---|
| 173 | \o \c{-arch x86_64}
|
|---|
| 174 | \row
|
|---|
| 175 | \o PPC, 32-bit
|
|---|
| 176 | \o \c{-arch ppc}
|
|---|
| 177 | \row
|
|---|
| 178 | \o PPC, 64-bit
|
|---|
| 179 | \o \c{-arch ppc64}
|
|---|
| 180 | \endtable
|
|---|
| 181 |
|
|---|
| 182 | If there are no \c{-arch} flags specified, configure builds for the 32-bit
|
|---|
| 183 | architecture, if you are currently on one. Universal binaries were initially
|
|---|
| 184 | used to simplify the PPC to Intel migration. You can use \c{-universal} to
|
|---|
| 185 | build for both the 32-bit Intel and PPC architectures.
|
|---|
| 186 |
|
|---|
| 187 | \note The \c{-arch} flags at configure time only affect how Qt is built.
|
|---|
| 188 | Applications are by default built for the 32-bit architecture you are
|
|---|
| 189 | currently on. To build a universal binary, add the architectures to the
|
|---|
| 190 | CONFIG variable in the .pro file:
|
|---|
| 191 |
|
|---|
| 192 | \code
|
|---|
| 193 | CONFIG += x86 ppc x86_64 ppc64
|
|---|
| 194 | \endcode
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 | \section1 Day-to-Day Application Development on OS X
|
|---|
| 198 |
|
|---|
| 199 | On the command-line, applications can be built using \c qmake and \c make.
|
|---|
| 200 | Optionally, \c qmake can generate project files for Xcode with
|
|---|
| 201 | \c{-spec macx-xcode}. If you are using the binary package, \c qmake
|
|---|
| 202 | generates Xcode projects by default; use \c{-spec macx-gcc} to generate
|
|---|
| 203 | makefiles.
|
|---|
| 204 |
|
|---|
| 205 | The result of the build process is an application bundle, which is a
|
|---|
| 206 | directory structure that contains the actual application executable. The
|
|---|
| 207 | application can be launched by double-clicking it in Finder, or by
|
|---|
| 208 | referring directly to its executable from the command line, i. e.
|
|---|
| 209 | \c{myApp.app/Contents/MacOS/myApp}.
|
|---|
| 210 |
|
|---|
| 211 | If you wish to have a command-line tool that does not use the GUI (e.g.,
|
|---|
| 212 | \c moc, \c uic or \c ls), you can tell \c qmake not to execute the bundle
|
|---|
| 213 | creating steps by removing it from the \c{CONFIG} in your \c{.pro} file:
|
|---|
| 214 |
|
|---|
| 215 | \code
|
|---|
| 216 | CONFIG -= app_bundle
|
|---|
| 217 | \endcode
|
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 | \section1 Deployment - "Compile once, deploy everywhere"
|
|---|
| 221 |
|
|---|
| 222 | In general, Qt supports building on one Mac OS X version and deploying on
|
|---|
| 223 | all others, both forward and backwards. You can build on 10.4 Tiger and run
|
|---|
| 224 | the same binary on 10.3 and 10.5.
|
|---|
| 225 |
|
|---|
| 226 | Some restrictions apply:
|
|---|
| 227 |
|
|---|
| 228 | \list
|
|---|
| 229 | \o Some functions and optimization paths that exist in later versions
|
|---|
| 230 | of Mac OS X will not be available if you build on an earlier
|
|---|
| 231 | version of Mac OS X.
|
|---|
| 232 | \o The CPU architecture should match.
|
|---|
| 233 | \o Cocoa support is only available for Mac OS X 10.5 and up.
|
|---|
| 234 | \endlist
|
|---|
| 235 |
|
|---|
| 236 | Universal binaries can be used to provide a smorgasbord of configurations
|
|---|
| 237 | catering to all possible architectures.
|
|---|
| 238 |
|
|---|
| 239 | Mac applications are typically deployed as self-contained application
|
|---|
| 240 | bundles. The application bundle contains the application executable as well
|
|---|
| 241 | as dependencies such as the Qt libraries, plugins, translations and other
|
|---|
| 242 | resources you may need. Third party libraries like Qt are normally not
|
|---|
| 243 | installed system-wide; each application provides its own copy.
|
|---|
| 244 |
|
|---|
| 245 | The most common way to distribute applications is to provide a compressed
|
|---|
| 246 | disk image (.dmg file) that the user can mount in Finder. The Mac
|
|---|
| 247 | deployment tool (macdeployqt) can be used to create the self-contained bundles, and
|
|---|
| 248 | optionally also create a .dmg archive. See the
|
|---|
| 249 | \l{Deploying an Application on Mac OS X}{Mac deployment guide} for more
|
|---|
| 250 | information about deployment. It is also possible to use an installer
|
|---|
| 251 | wizard. More information on this option can be found in
|
|---|
| 252 | \l{http://developer.apple.com/mac/}{Apple's documentation}.
|
|---|
| 253 | */
|
|---|
| 254 |
|
|---|