Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

Running qmakeqmake Advanced Usage

qmake Platform Notes

Many cross-platform projects can be handled by theqmake's basic configuration features. On some platforms, it is sometimes useful, or even necessary, to take advantage of platform-specific features.qmake knows about many of these features, and these can be accessed via specific variables that only have an effect on the platforms where they are relevant.

Mac OS X

Features specific to this platform include support for creating universal binaries, frameworks and bundles.

Source and Binary Packages

The version ofqmake supplied in source packages is configured slightly differently to that supplied in binary packages in that it uses a different feature specification. Where the source package typically uses themacx-g++ specification, the binary package is typically configured to use themacx-xcode specification.

Users of each package can override this configuration by invokingqmake with the-spec option (seeRunning qmake for more information). This makes it possible, for example, to useqmake from a binary package to create a Makefile in a project directory with the following command line invocation:

qmake -spec macx-g++

Using Frameworks

qmake is able to automatically generate build rules for linking against frameworks in the standard framework directory on Mac OS X, located at/Library/Frameworks/.

Directories other than the standard framework directory need to be specified to the build system, and this is achieved by appending linker options to theQMAKE_LFLAGS variable, as shown in the following example:

QMAKE_LFLAGS += -F/path/to/framework/directory/

The framework itself is linked in by appending the-framework options and the name of the framework to theLIBS variable:

LIBS += -framework TheFramework

Creating Frameworks

Any given library project can be configured so that the resulting library file is placed in aframework, ready for deployment. To do this, set up the project to use thelib template and add thelib_bundle option to theCONFIG variable:

TEMPLATE = libCONFIG += lib_bundle

The data associated with the library is specified using theQMAKE_BUNDLE_DATA variable. This holds items that will be installed with a library bundle, and is often used to specify a collection of header files, as in the following example:

FRAMEWORK_HEADERS.version = VersionsFRAMEWORK_HEADERS.files = path/to/header_one.h path/to/header_two.hFRAMEWORK_HEADERS.path = HeadersQMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS

Here, theFRAMEWORK_HEADERS variable is a user-defined variable that is used to define the headers required to use a particular framework. Appending it to theQMAKE_BUNDLE_DATA variable ensures that the information about these headers are added to the collection of resources that will be installed with the library bundle. Also, the framework's name and version are specified byQMAKE_FRAMEWORK_BUNDLE_NAME andQMAKE_FRAMEWORK_VERSION variables. By default, the values used for these are obtained from theTARGET andVERSION variables.

SeeDeploying an Application on Mac OS X for more information about deploying applications and libraries.

Creating Universal Binaries

To create a universal binary for your application, you need to be using a version of Qt that has been configured with the-universal option.

The architectures to be supported in the binary are specified with theCONFIG variable. For example, the following assignment causesqmake to generate build rules to create a universal binary for both PowerPC and x86 architectures:

CONFIG += x86 ppc

Additionally, developers using a PowerPC-based platform need to set theQMAKE_MAC_SDK variable. This process is discussed in more detail in thedeployment guide for Mac OS X.

Creating and Moving Xcode Projects

Developers on Mac OS X can take advantage ofqmake's support for Xcode project files, as described inQt is Mac OS X Native, by runningqmake to generate an Xcode project from an existingqmake project files. For example:

qmake -spec macx-xcode project.pro

Note that, if a project is later moved on the disk,qmake must be run again to process the project file and create a new Xcode project file.

On supporting two build targets simultaneously

Implementing this is currently not feasible, because theXCode concept of Active Build Configurations is conceptually different from the qmake idea of build targets.

TheXCode Active Build Configurations settings are for modifying xcode configurations, compiler flags and similar build options. Unlike Visual Studio,XCode does not allow for the selection of specific library files based on whether debug or release build configurations are selected. The qmake debug and release settings control which library files are linked to the executable.

It is currently not possible to set files inXCode configuration settings from the qmake generated xcode project file. The way the libraries are linked in the "Frameworks & Libraries" phase in theXCode build system.

Furthermore, the selected "Active Build Configuration" is stored in a .pbxuser file, which is generated by xcode on first load, not created by qmake.

Windows

Features specific to this platform include support for creating Visual Studio project files and handling manifest files when deploying Qt applications developed using Visual Studio 2005.

Creating Visual Studio Project Files

Developers using Visual Studio to write Qt applications can use the Visual Studio integration facilities provided with the Qt Commercial Edition and do not need to worry about how project dependencies are managed.

However, some developers may need to import an existingqmake project into Visual Studio.qmake is able to take a project file and create a Visual Studio project that contains all the necessary information required by the development environment. This is achieved by setting theqmakeproject template to eithervcapp (for application projects) orvclib (for library projects).

This can also be set using a command line option, for example:

qmake -tp vc

It is possible to recursively generate.vcproj files in subdirectories and a.sln file in the main directory, by typing:

qmake -tp vc -r

Each time you update the project file, you need to runqmake to generate an updated Visual Studio project.

Note:If you are using the Visual Studio Add-in, you can import.pro files via theQt->Import from .pro file menu item.

Visual Studio 2005 Manifest Files

When deploying Qt applications built using Visual Studio 2005, it is necessary to ensure that the manifest file, created when the application was linked, is handled correctly. This is handled automatically for projects that generate DLLs.

Removing manifest embedding for application executables can be done with the following assignment to theCONFIG variable:

CONFIG -= embed_manifest_exe

Also, the manifest embedding for DLLs can be removed with the following assignment to theCONFIG variable:

CONFIG -= embed_manifest_dll

This is discussed in more detail in thedeployment guide for Windows.

Symbian Platform

Features specific to this platform include handling of static data, capabilities, stack and heap size, compiler specific options, and unique identifiers for the application or library.

Handling of Static Data

If the application uses any static data, the build system needs to be informed about it. This is because Symbian tries to save memory if no static data is in use.

To specify that static data support is desired, add this to the project file:

TARGET.EPOCALLOWDLLDATA = 1

The default value is zero.

Stack and Heap Size

The Symbian platform uses predefined sizes for stacks and heaps. If an application exceeds either limit, it may crash or fail to complete its task. Crashes that seem to have no reason can often be traced back to insufficient stack and/or heap sizes.

The stack size has a maximum value, whereas the heap size has a minimum and a maximum value, all specified in bytes. The minimum value prevents the application from starting if that amount of memory is not available. The minimum and maximum values are separated by a space. For example:

TARGET.EPOCHEAPSIZE = 10000 10000000TARGET.EPOCSTACKSIZE = 0x8000

The default values depend on the version of the Symbian SDK you're using, however, the Qt toolchain sets this to the maximum possible value and this should not be changed.

Compiler-Specific Options

General compiler options can as usual be set usingQMAKE_CFLAGS andQMAKE_CXXFLAGS. In order to set specific compiler options,QMAKE_CFLAGS.<compiler> andQMAKE_CXXFLAGS.<compiler> can be used.<compiler> can be eitherCW for the WINSCW architecture (emulator), orARMCC for the ARMv5 architecture (hardware), orGCCE for the ARMv5 architecture (hardware).

Here is an example:

QMAKE_CXXFLAGS.CW += -O2QMAKE_CXXFLAGS.ARMCC += -O0

Unique Identifiers

Symbian applications may have unique identifiers attached to them. Here is how to define them in a project file:

There are four available types of IDs supported:UID2,UID3,SID, andVID. They are specified like this:

TARGET.UID2 = 0x00000001TARGET.UID3 = 0x00000002TARGET.SID = 0x00000003TARGET.VID = 0x00000004

IfSID is not specified, it defaults to the same value asUID3. IfUID3 is not specified, qmake will automatically generate aUID3 suitable for development and debugging. This value should be manually specified for applications that are to be released. See theSymbian Signed Web site for information about obtaining an official UID. BothSID andVID default to empty values.

There exists one UID1 too, but this should not be touched by any application.

The UID2 has a specific value for different types of files; e.g. apps/exes are always 0x100039CE. The toolchain will set this for value for the most common file types like, EXE/APP and shared library DLL.

For more information about unique identifiers and their meaning for Symbian applications, please refer to theUID Q&As (Symbian Signed) page in theForum Nokia Wiki for more information.

Capabilities

Capabilities define extra privileges for the application, such as the ability to list all files on the file system. Capabilities are defined in the project file like this:

TARGET.CAPABILITY += AllFiles

It is also possible to specify which capabilitiesnot to have, by first specifyingALL and then list the unwanted capabilities with a minus in front of them, like this:

TARGET.CAPABILITY = ALL -TCB -DRM -AllFiles

For more information about capabilities, please refer to the Symbian SDK documentation.

Running qmakeqmake Advanced Usage

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp