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.
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). With CDT 4.0, 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).
The C++ Project wizard opens. Click here to see an illustration.
By default, the CDT filters the Toolchain and Project types that currently display in those lists are based on the language support for the C++ Project wizard you selected for this tutorial.
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.
If the C++ perspective is not currectly 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.
Click here to see an illustration.
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.
You should now see the new project in C/C++ Projects view.
If C/C++ perspective was not set as current before, it will be selected now.
Now, you will create a new .cpp file (such as main.cpp) that will contain some code that you will copy from another file into an editor.
You should now see the new project in the C/C++ Projects view under the project, and the new file opens in the Editor view.
You can double click the main.cpp tab in the Editor
view to expand the view.
Note: Leave a blank line at the end of the code because it is required by some compilers.
On the tab in the Editor view, an asterisk character ("*") prefixes the file name. The asterisk indicates that the file has changed but has not been saved.
If you select an item from the Outline view, the corresponding text in the editor is highlighted.
You can read through the build messages in the Console view. The project should build successfully, showing the following message:
Finished building target: HelloWorld.exe
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.
A new Run Configuration is created. Its name and path to executable are provided by the project ('HelloWorld' in our case).
Now, you should now see the Hello World application running in the Console view. The Console also shows which application is running in a title bar. You can configure this view to display different elements (such as user input elements) using different colors.
The title bar in the Console view shows you when the program has terminated.