Building C/C++ projects

The CDT uses the same make utility and makefile used on the command line. The CDT can generate makefiles automatically when you create a Managed Make C project or a Managed Make C++ project. You have the option of creating a Standard Make C project or a Standard Make C++ project and providing the makefile.

Required utilities

You must install and configure the following utilities:

Cygwin contains these utilities for a Windows environment, while running the cygwin installation ensure gcc and make are selected, they are not installed by default. For more information, see http://www.cygwin.com. Red Hat users, all you need to build your project is included in the Red Hat Linux installation. For other operating systems please refer to your installation documentation.

To test if your compiler was installed correctly open a command prompt or terminal window and type g++ or make. An error message stating the command was not found or not recognized means that the utility is not installed or your path is not configured correctly.

To check your path at a command prompt and the appropriate path command (i.e. enter PATH for windows users or echo $PATH for linux users). Make sure that the path to your build utility is defined (example PATH=c:\cygwin\bin).

Build terminology

The CDT uses a number of terms to describe the scope of the build.

Build Project

This is an incremental build (make all). Only the components affected by modified files in that particular project are built.

Rebuild Project

Builds every file in the project whether or not a file has been modified since the last build. A rebuild is a clean followed by a build.

For more information on builds, see:

Build-related information is displayed as follows:

For more information about the Tasks view, see Workbench User Guide > Reference > User interface information > Views and editors > Tasks view.

Getting a makefile

You can either create a C project for which you supply the makefile or create a C project for which the CDT generates makefiles automatically.

To create a new project, from the menu bar choose File > New > Project. In the dialog that appears:

Setting build preferences

You can set build preferences in Eclipse:

Build order
If certain projects must be built before others, you can set the build order. If your project refers to another project, the CDT must build the other project first. To set the build order, from the menu bar select Window > Preferences > Build Order.

When you set the build order, the CDT does not rebuild projects that depend on a project; you must rebuild all projects to ensure all changes are propagated.

Automatic save
You can set the CDT to perform an automatic save of all modified resources when you perform a manual build; from the menu bar, select Windows > Preferences > Workbench. By default, this feature is disabled.

Controlling the building of your project

The C/C++ compiler that a project uses is controlled by the project's Properties setting. To view a project's properties, right-click on the project and select Properties. In the dialog that appears, the C/C++ Make Project page enables you to control a variety of settings, including:

Build Setting
Controls whether the compiler will Stop On Error or Keep Going On Error. Choosing Keep Going On Error will force the compiler to attempt to build all referenced projects even if the current project has errors.
Build Command
Controls which compiler is used. By default the compiler is C Builder (gcc).
Workbench Build Behavior
Controls the auto-build on save feature and what operations are performed during a build and rebuild.

The External Tools Builders page enables you to add, reorder, or remove external build tools.

Viewing build information

Build-related information is displayed as follows:

Related concepts
CDT Projects
Project file views

Related tasks
Defining project properties
Building

IBM Copyright Statement
IBM Copyright Statement