Building the Target

This topic describes how to build the target using the Xcode IDE and also documents the build steps using the xcodebuild utility.

Building using the Xcode IDE

To build the active target and configuration in Xcode, choose Build from the Build menu or click the Build button in the toolbar. To view the results of your build, choose Build Results from the Build menu in the Xcode toolbar. You can view additional build details by clicking the build transcript icon in the Build Results window.

To build an individual file and not the entire project, select the file under the target and then choose Compile from the Action drop-down menu in the toolbar.

Note

Choosing Build from the Build menu or clicking the Build button in the toolbar builds the target specified in the Active Target drop-down menu in the toolbar and not the target or source file currently selected in the Groups & Files list.

You can change the compilation order of the Xcode target. To re-order the files listed under a target's Compile Sources, click a source and drag it before or after other compilations.

Building using the xcodebuild Utility

You can also use the xcodebuild utility to build a target. This utility uses the Xcode project file settings to build target projects from the command line. If you have previously configured your Xcode project to build with the Intel compiler, xcodebuild will invoke that compiler from the command line. The basic steps are as follows:

  1. Check that the Xcode project is configured to use the Intel C++ compiler.

  2. Launch a terminal window by selecting Finder > Applications > Utilities > Terminal.

  3. Change directories to the project directory containing the Xcode project file.

  4. Issue an xcodebuild command similar to the following:
    xcodebuild -project test2.xcodeproj -target testapp -configuration Debug

  5. To run the program, type the following:
    ./build/Debug/testapp

Building a 64-bit Executable

To build a 64-bit executable from within Xcode, edit the executable's target and replace "and" with "to" change the Architectures setting to x86_64 (you may need to manually enter this selection). This produces a 64-bit binary for Intel® 64 architecture.

Note

The Intel C++ Compiler generates code solely for Intel architectures.

Understanding the LP64 Data Model

The 64-bit data model used by Mac OS is known as LP64. The use of the LP64 data model ensures that source code created on other platforms can be easily ported to the Mac OS platform.

The LP64 data model defines these C/C++ types as follows:

The following C/C++ restrictions and guidelines apply:

Conditionalizing 64-Bit Compilation using Macros

Use the __LP64__ macro to conditionally compile 64-bit code or define 64-bit APIs.