In this tutorial, you will use the CDT to create a simple 'Hello World' application. This tutorial describes the process of creating a new C++ project where the build is automatically managed by the CDT, and running the program.
Note: In earlier versions of the CDT, there were two separate project types: Managed make (automatically generated a makefile) and Standard make (required the user's makefile to build). Now with CDT, you now select a project type, and that determines what build system will be used.
To create a simple "Hello World" application using the CDT, you will perform the following steps:
Click here to see an illustration (displayed in a separate window).
Click here to see an illustration.
The C++ Project wizard opens.
By default, the CDT filters the Toolchain and Project types that it displays in those lists based on the language support for the C++ Project wizard you selected for this tutorial.
In the Project name field, type a name for the project, such as Hello World.
From the Project types list, expand Executable and select Hello World C++ Project. This project type provides a simple Hello World application in C++, and the makefile is automatically created by the CDT.
Select a required toolchain from the Toolchain list.
A toolchain is a set of tools (such as a compiler, linker, and assembler) intended to build your project. Additional tools, such as a debugger, can be associated with a toolchain. There can be several toolchains available, depending on the compilers installed on your system.
Click Next.
The Select Configurations window displays a list of configurations based on the project type and toolchain(s) you selected earlier.
Click here to see an illustration.
Optional: If you want to change the default project settings, click Advanced Settings.
This opens the project properties dialog for your new project allowing you change any of the project specific settings, such as includes paths, compiler options, and libraries.
Click here to see an illustration.
Click here to see an illustration.
Click Finish.
If the C++ perspective is not currently set as the default, you are prompted to determined if you would like to this project to be associated with the C/C++ perspective. Click Yes.
Click here to see an illustration.
A project is created with the default settings and a full set of configurations based on the project type and toolchain you selected. You should now see the new project in C/C++ Projects view.
Click here to see an illustration.
Note that the file may be within a folder inside the project, e.g. the "src" folder.
This file opens in a default editor. It contains C++ template code for the Hello World example project you selected earlier.
Note: You can specify a different editor, and add or modify existing code templates in Window > Preferences.
In addition, the Outline view has also been populated with objects created from your code.
Next, you will need to build your project before you can run it.
Note: If a build generates any errors or warnings, you can see those in the Problems view. If you encounter difficulty, see the topics Building C/C++ projects and Before you begin
.
You will also see the Outline view has also been populated with objects created from your code. If you select an item from the Outline view, the corresponding text in the editor is highlighted.
To run your application:
A new Run Configuration is created. Its name and path to the executable are provided by the project ('Hello World' in our case).
Now, you should see the Hello World application running in the Console view. The Console also shows which application is running in a title bar.