////
Copyright (c) 2000, 2025 Contributors to the Eclipse Foundation
This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/legal/epl-2.0/

SPDX-License-Identifier: EPL-2.0
////

// pull in shared headers, footers, etc
:docinfo: shared

// support image rendering and table of contents within GitHub
ifdef::env-github[]
:imagesdir: ../../images
:toc:
:toc-placement!:
endif::[]

// enable support for button, menu and keyboard macros
:experimental:

// Until ENDOFHEADER the content must match adoc-headers.txt for consistency,
// this is checked by the build in do_generate_asciidoc.sh, which also ensures
// that the checked in html is up to date.
// do_generate_asciidoc.sh can also be used to apply this header to all the
// adoc files.
// ENDOFHEADER

== Tutorial: Creating a Managed Build System Makefile project

In this tutorial, you will use the CDT to create a simple 'Hello World'
application. This tutorial describes the process of creating a new {cpp}
project where the build is automatically managed by the CDT, and running
the program.

To create a simple "Hello World" application using CDT, perform the
following general steps:

. link:#cdt_create[Creating a project]
. link:#cdt_build[Reviewing the code and building the project]
. link:#cdt_running[Running the application]

'''''

=== Step 1: [[cdt_create]]Creating a project

. Select *File > New > Project*.
 +
image:cdt_w_basic02.png[Select File > New > Project menu
option,width=591,height=183]
+
. Select the type of project to create. For this tutorial, expand the
*C/{cpp}* folder and select *C/{cpp} Project* and click *Next*.
 +
image:cdt_w_basic03a.png[Select project type]
 +
. Select *{cpp} Managed Build* and click *Next*.
 +
image:cdt_w_basic03b.png[Select {cpp} Managed Build]
 +
. The *{cpp} Project* wizard opens.
+
image:cdt_w_basic04.png[{cpp} project
wizard,width=525,height=576]
 +
By default, the CDT filters the *Toolchain* and *Project types* that it
displays in those lists based on the language support for the {cpp}
Project wizard you selected for this tutorial.
+
[loweralpha]
.. In the *Project name* field, type a name for the project, such as
*HelloWorld*.
+
.. From the *Project type* list, expand *Executable* and select *Hello
World {cpp} Project*. This project type provides a simple Hello World
application in {cpp}, 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*.
+
. Specify the *Basic Properties* for the new project, such as your
author, copyright, and source information, then click *Next*.
 +
image:cdt_w_basic06a.png[Basic properties of a
project,width=525,height=576]
 +
. The *Select Configurations* page displays a list of configurations
based on the project type and toolchain(s) selected earlier.
 +
image:cdt_w_basic07.png[Select configurations
page,width=525,height=576]
 +
*OPTIONAL*: If you want to change the default project settings, click
*Advanced Setting* to open the
xref:../reference/cdt_u_prop_all.adoc[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 *Finish*.

*NOTE* If the *{cpp} perspective* is not currently set as the default, you
are prompted to determine if you would like to this project to be
associated with the C/{cpp} perspective. Click *Yes*.

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
xref:../reference/cdt_u_project_explorer_view.adoc[Project Explorer]
view.

image:cdt_w_basic12.png[New project displayed in
the Project Explorer view,width=423,height=283]

'''''

=== Step 2: [[cdt_build]]Reviewing the code and building the project

. From the *Project Explorer* view, double-click the .cpp file created
for your project, for example, [.typewriter]#HelloWorld.cpp#. You'll
find it within the project "[.typewriter]#src#" folder.
+
This file opens in a default editor. It contains {cpp} template code for
the Hello World example project you selected earlier. In addition, the
xref:../reference/cdt_u_outline_view.adoc[Outline] view has also been
populated with objects created from your code.
 +
image:cdt_w_basic13.png[C Editor with Outline
view,width=731,height=333]
 +
Next, you will need to build your project before you can run it.
 +
. Build your project by pressing *CTRL+B*, or select the project in the
*Project Explorer* view and select *Project > Build Project*.
+
*NOTE:* If a build generates any errors or warnings, you can see those
in the xref:../reference/cdt_u_problems_view.adoc[Problems] view. If you
encounter difficulty, see the topics
xref:../concepts/cdt_c_build_over.adoc[Building C/{cpp} projects] and
xref:../concepts/cdt_c_before_you_begin.adoc[Before you begin]
.
. Read through the build messages in the
xref:../reference/cdt_u_console_view.adoc[Console] view. The project
should build successfully.
+
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.

'''''

=== Step 3: [[cdt_running]]Running the application

To run your application:

. Within the C/{cpp} Perspective, click *Run > Run Configurations...*.
+
. Select *C/{cpp} Application*.
+
. Click *New*.
+
A new Run Configuration is created. Its name and path to the executable
are provided by the project ('Hello World' in our case).
. Click *Run*.
+
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.
+
. You can click the other views to see the information that they
contain.

