- Qbs Manual
- Module cpp
- Qt Build Suite 1.4.1

# Module cpp

The `cpp` module contains the properties and rules for toolchains of the C/C++ family. On OS X this includes support for Objective-C/C++.

## General Properties

### allowUnresolvedSymbols

Type: | `bool`
Default: | `false`

Switch this on if you want the linking step to succeed even if the resulting binary contains unresolved symbols. Normally this makes little sense, but in special cases it is possible that the respective symbols will be available at load time even if they are not present during linking.

### architecture

Type: | `string`
Default: | `qbs.architecture`

Target architecture. See `qbs.architecture`.

### debugInformation

Type: | `bool`
Default: | `qbs.debugInformation`

Generate debug information. See `qbs.debugInformation`.

### separateDebugInformation

Type: | `bool`
Default: | `false` for gcc/clang, `true` for MSVC

Whether to store debug information in an external file or bundle instead of within the binary.

### defines

Type: | `stringList`
Default: | `undefined`

List of preprocessor macros that gets passed to the compiler. To set macro values use the following syntax:

    cpp.defines: ["USE_COLORS=1", 'COLOR_STR="blanched almond"']

### platformDefines

Type: | `stringList`
Default: | `undefined`

List of preprocessor macros that are used for all projects that are built for the current target platform. User project files usually do not set this property.

### compilerDefines

Type: | `stringList`
Default: | `undefined`

List of preprocessor macros that are used for all projects that are using the current toolchain. User project files usually do not set this property.

### includePaths

Type: | `pathList`
Default: | `undefined`

List of include paths. Relative paths are considered to be relative to the .qbs product file they are used in.

### systemIncludePaths

Type: | `pathList`
Default: | `undefined`

List of include paths that are passed as system include paths to the compiler. For header files in those paths warnings will be ignored. Relative paths are considered to be relative to the .qbs product file they are used in.

### libraryPaths

Type: | `pathList`
Default: | `undefined`

List of library search paths. Relative paths are considered to be relative to the .qbs product file they are used in.

### dynamicLibraries

Type: | `stringList`
Default: | `undefined`

List of dynamic libraries to be linked. If the library is part of your project, consider using a Depends item instead.

### staticLibraries

Type: | `stringList`
Default: | `undefined`

List of static libraries to be linked. If the library is part of your project, consider using a Depends item instead.

### prefixHeaders

Type: | `pathList`
Default: | `undefined`

List of files to automatically include at the beginning of each source file in the product.

### precompiledHeader

Type: | `path`
Default: | `undefined`

Name of the header file to be precompiled.

If you want to use the same precompiled header for all languages (C, C++, Objective-C and Objective-C++), set this property and ensure that the header contains appropriate ifdefs.

Otherwise, use the `cPrecompiledHeader`, `cppPrecompiledHeader`, `objcPrecompiledHeader` and `objcppPrecompiledHeader` to specify precompiled headers per-language.

### cPrecompiledHeader

Type: | `path`
Default: | `precompiledHeader`

Name of the C header file to be precompiled.

### cxxPrecompiledHeader

Type: | `path`
Default: | `precompiledHeader`

Name of the C++ header file to be precompiled.

### objcPrecompiledHeader

Type: | `path`
Default: | `precompiledHeader`

Name of the Objective-C header file to be precompiled.

### objcxxPrecompiledHeader

Type: | `path`
Default: | `precompiledHeader`

Name of the Objective-C++ header file to be precompiled.

### precompiledHeaderDir

Type: | `path`
Default: | `product.buildDirectory`

The directory that will contain the precompiled header files. Usually you won't need to set this.

### optimization

Type: | `string`
Default: | `qbs.optimization`

Optimization level. See `qbs.optimization`.

### treatWarningsAsErrors

Type: | `bool`
Default: | `false`

Warnings will be handled as errors and cause the build to fail.

### warningLevel

Type: | `string`
Allowed Values: | `"none"`, `"all"`
Default: | `"all"`

Specifies the warning level for the compiler.

### commonCompilerFlags

Type: | `stringList`
Default: | undefined

Flags that are added to all compilation commands independently of the language.

### compilerVersionMajor

Type: | `int`
Default: | undefined

The major version of the compiler.

### compilerVersionMinor

Type: | `int`
Default: | undefined

The minor version of the compiler.

### compilerVersionPatch

Type: | `int`
Default: | undefined

The patch level component of the compiler version.

### cppFlags

Type: | `stringList`
Default: | undefined

Additional flags for the C preprocessor.

### cFlags

Type: | `stringList`
Default: | undefined

Additional flags for the C compiler.

### cxxFlags

Type: | `stringList`
Default: | undefined

Additional flags for the C++ compiler.

### cLanguageVersion

Type: | `string`
Default: | undefined
Allowed Values: | `"c89"`, `"c99"`, `"c11"`

The version of the C standard with which the code must comply. If this property is set, corresponding compiler and/or linker flags will be added, depending on the toolchain. If the value is left undefined, the compiler default will be used.

### cxxLanguageVersion

Type: | `string`
Default: | undefined
Allowed Values: | `"c++98"`, `"c++11"`, `"c++14"`

The version of the C++ standard with which the code must comply. If this property is set, corresponding compiler and/or linker flags will be added, depending on the toolchain. If the value is left undefined, the compiler default will be used.

### cxxStandardLibrary

Type: | `string`
Default: | undefined
Possible Values: | `"libstdc++"`, `"libc++"`

The C++ standard library to link to. If this property is set, corresponding compiler and/or linker flags will be added, assuming the value is valid for the current toolchain. If the value is left undefined, the compiler default will be used.

### objcFlags

Type: | `stringList`
Default: | undefined

Additional flags for the Objective-C compiler.

### objcxxFlags

Type: | `stringList`
Default: | undefined

Additional flags for the Objective-C++ compiler.

### linkerFlags

Type: | `stringList`
Default: | undefined

Additional flags for the linker.

### linkerScripts

Type: | `pathList`
Default: | `undefined`

List of linker script files.

### compilerName

Type: | `string`
Default: | determined by qbs-setup-toolchains

Name of the main compiler binary. This is set in the build profile.

### compilerPath

Type: | `string`
Default: | determined by qbs-setup-toolchains

Full path of the main compiler binary. This is set in the build profile. If the toolchain provides different compilers for different languages, then `compilerPathByLanguage` is used.

### compilerPathByLanguage

Type: | `string` to `string` map
Default: | determined by qbs-setup-toolchains

Maps file tags to full paths of compiler binaries. This is set in the build profile.

### compilerWrapper

Type: | `stringList`
Default: | `undefined`

Wrapper binary and its arguments for wrapping compiler calls. This is useful for compiler wrappers like ccache and alike.

### linkerName

Type: | `string`
Default: | determined by qbs-setup-toolchains

Name of the linker binary. This is set in the build profile.

### linkerPath

Type: | `string`
Default: | determined by qbs-setup-toolchains

Full path of the linker binary. This is set in the build profile.

### entryPoint

Type: | `string`
Default: | `undefined`

Name of the entry point of an executable or dynamic library. If this property is undefined, the toolchain's default is used.

### runtimeLibrary

Type: | `string`
Default: | `"dynamic"` for MSVC, `undefined` for others

Type of the used runtime library. Accepted values are `"static"` and `"dynamic"`. If this property is set to `undefined`, then the default runtime library of the toolchain is used.

Note: For MSVC the default value is `"dynamic"`.

Note: At the moment this property is only functional for MSVC.

## Properties Specific to iOS and OS X

### frameworkPaths

Type: | `pathList`
Default: | `undefined`

List of framework search paths. Relative paths are considered to be relative to the .qbs product file they are used in.

### systemFrameworkPaths

Type: | `pathList`
Default: | `undefined`

List of framework search paths. Relative paths are considered to be relative to the .qbs product file they are used in. Header files in frameworks in those paths will not cause warnings.

### frameworks

Type: | `stringList`
Default: | `undefined`

List of frameworks to be linked. If the framework is part of your project, consider using a Depends item instead.

### weakFrameworks

Type: | `stringList`
Default: | `undefined`

List of frameworks to be weakly linked. If the framework is part of your project, consider using a Depends item instead.

### installNamePrefix

Type: | `string`
Default: | `undefined`

The prefix for the internal install name (LC_ID_DYLIB) of a dynamic library on Darwin (OS X and iOS). Typically this should be set to `"@rpath"` on modern platforms that support it, which includes OS X 10.5 and above, and all versions of iOS.

### automaticReferenceCounting

Type: | `bool`
Default: | `undefined`

Whether to enable Automatic Reference Counting (ARC) for Objective-C and Objective-C++ source code. If `undefined`, uses the compiler default (probably `false`).

### requireAppExtensionSafeApi

Type: | `bool`
Default: | `undefined`

Whether to enforce the use of only app-extension-safe APIs on OS X and iOS. This is necessary for building Application Extensions in OS X Yosemite and iOS 8 and above. If `undefined`, uses the compiler and linker defaults (probably `false`).

## Properties Specific to iOS

### minimumIosVersion

Type: | `string`
Default: | undefined, but may be set by generated profiles

A version number in the format [major].[minor] indicating the earliest version of OS X that the product should run on. Passes -miphoneos-version-min=<version> to the compiler. If undefined, compiler defaults will be used.

## Properties Specific to OS X

### minimumOsxVersion

Type: | `string`
Default: | undefined, but may be set by generated profiles

A version number in the format [major].[minor] indicating the earliest version of OS X that the product should run on. Passes -mmacosx-version-min=<version> to the compiler. If undefined, compiler defaults will be used.

## Properties Specific to Unix Platforms

### archiverName

Type: | `string`
Default: | `"ar"`

Name of the archiver binary. This is set in the build profile.

### archiverPath

Type: | `string`
Default: | determined by qbs-setup-toolchains

Full path of the archiver binary. This is set in the build profile.

### exportedSymbolsCheckMode

Type: | `string`
Default: | "ignore-undefined"

Controls how Qbs determines whether an updated dynamic library causes relinking of dependents. The default value is `"ignore-undefined"`, which means that undefined symbols being added or removed do not cause any relinking. If that should happen, for example because dependent products are linked with an option such as `"--no-undefined"`, then this property can be set to `"strict"`.

### nmName

Type: | `string`
Default: | `"nm"`

Name of the nm binary. This is set in the build profile.

### nmPath

Type: | `string`
Default: | determined by qbs-setup-toolchains

Full path of the nm binary. This is set in the build profile.

### objcopyName

Type: | `string`
Default: | `"objcopy"`

Name of the objcopy binary. This is set in the build profile.

### objcopyPath

Type: | `string`
Default: | determined by qbs-setup-toolchains

Full path of the objcopy binary. This is set in the build profile.

### stripName

Type: | `string`
Default: | `"strip"`

Name of the strip binary. This is set in the build profile.

### stripPath

Type: | `string`
Default: | determined by qbs-setup-toolchains

Full path of the strip binary. This is set in the build profile.

### dsymutilPath

Type: | `string`
Default: | determined by qbs-setup-toolchains

Full path of the dsymutil binary. This is set in the build profile.

### dsymutilFlags

Type: | `stringList`
Default: | undefined

Additional flags for the dsymutil tool.

### positionIndependentCode

Type: | `bool`
Default: | `undefined`

Generate position independent code. If this property is `undefined`, then position independent code is generated for libraries, but not for applications.

### rpaths

Type: | `stringList`
Default: | `undefined`

List of rpaths that are passed to the linker.

### useRPaths

Type: | `bool`
Default: | `true`

Set this property to `false` to prevent the linker from writing rpaths to the binary.

### visibility

Type: | `string`
Allowed Values: | `"default"`, `"hidden"`, `"hiddenInlines"`, `"minimal"`
Default: | `"default"`

Visibility level for exported symbols. The `"minimal"` value combines `"hidden"` and `"hiddenInlines"`.

## Properties Specific to Windows

### windowsApiCharacterSet

Type: | `string`
Allowed Values: | `"unicode"`, `"mbcs"`, `undefined`
Default: | `"unicode"`

Specifies the character set used in the Win32 API. "unicode" will define the preprocessor symbols UNICODE and _UNICODE, "mbcs" will define _MBCS, and setting the value to undefined will use the default character set.

### minimumWindowsVersion

Type: | `string`
Default: | undefined, but may be set by generated profiles

A version number in the format [major].[minor] indicating the earliest version of Windows that the product should run on. Defines WINVER, _WIN32_WINNT, and _WIN32_WINDOWS, and applies a version number to the linker flags /SUBSYSTEM and /OSVERSION for MSVC or -Wl,--major-subsystem-version, -Wl,--minor-subsystem-version, -Wl,--major-os-version and -Wl,--minor-os-version for MinGW. If undefined, compiler defaults will be used.