Compiling, Building, and Running Applications

From RAD Studio
Jump to: navigation, search

Go Up to Compiling, Building, and Running Applications Index


As you develop your application in the IDE, you can compile (or make), build, and run the application in the IDE. All three operations can produce an executable (such as .exe, .dll, .obj, or .bpl). However, the three operations differ slightly in behavior:

  • Compile (Project > Compile) or, for C++, Make (Project > Make) compiles only those files that have changed since the last build as well as any files that depend on them. Compiling or making does not execute the application (see Run).
  • Build (Project > Build) compiles all of the source code in the current project, regardless of whether any source code has changed. Building is useful when you are unsure which files have changed, or if you have changed project or compiler options.
  • Run (Run > Run (F9)) compiles any changed source code and, if the compile is successful, executes your application, allowing you to use and test it in the IDE.

To delete all the generated files from a previous build, use the Clean command, available on the context menu of the project node in the Project Manager.

Compiler Options

You can set many of the compiler options for a project by choosing Project > Options and selecting a compiler-related page. For example, most of the options on both the Delphi Compiler page and the C++ Compiler page correspond to compiler options that are described in the online Help for that page.

To specify additional compiler options, you can invoke the compiler from the command line. For a complete list of the Delphi compiler options and information about running the Delphi compiler from the command line, see Delphi Language Guide in the Contents pane.

Compiler Status and Information

To display the current compiler options in the Messages window each time you compile your project, choose Tools > Options > Environment Options and select Show command line. The next time you compile a project, the Messages window displays the command used to compile the project and the response file. The response file lists the compiler options and the files to be compiled.

After you compile a project, you can display information about it by choosing Project > Information. The resulting Information dialog box displays the number of lines of source code compiled, the byte size of your code and data, the stack and file sizes, and the compile status of the project.

Compiler Errors

As you compile a project, compiler messages are displayed in the Messages window. For an explanation of a message, select the message and press F1.

Build Configurations

You can save certain project options as a named build configuration. You can specify the active build configuration for each of your projects, and you can change the active build configuration during project development. For example, you can set project options specific to debugging your project, save the options as the Debug build configuration, and then apply them as the active configuration while you debug the project.

The options in a build configuration are available on the Compiler, Compiler Messages, Linker, and Conditionals/Directories pages of the Project > Options dialog box.

By default, the IDE includes three configurations: Base, Debug, and Release. You can modify the options in any of these default configurations, and you can create new build configurations of your own. To activate a selected build configuration on specific projects or project groups, see Activating a Build Configuration for a Project. You can create and delete build configurations on the Configuration Manager.

Option Sets

In addition to build configurations, option sets are a way for you to save and selectively apply the build-related settings you have made on the Project > Options dialogs. Option sets are disk files with the extension .optset. You can apply an option set to the current build configuration by reference or by value.

Using MSBuild to Build Your Project

When you explicitly build a project, the IDE calls MSBuild, the Microsoft build engine. The build process is entirely transparent to developers. MSBuild is called as part of the commands to compile, build and run of the Project and Run menus. However, you can also invoke MSBuild.exe from the command line or by using the RAD Studio Command Prompt, available on the Start menu.

You Can Compile in the Background

If you enable Background Compilation on the Environment Options dialog box, you can run compile and build commands as background threads. See Background Compilation for more information.

See Also