Skip to main content
summaryrefslogtreecommitdiffstats
blob: 5e2ec1e052f01fec4de1d5a1458b3b71bffc1ac6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>New CDT Project with generated makefile - Tutorial</title>
	<link rel="stylesheet" type="text/css" href="../help.css">
<script language="JavaScript">
function newWin(url) {
	window.open(url, 'install_cdt', 'width=900, height=700, menubar=no, toolbar=no, status=no, resizable=yes, location=no, scrollbars=yes');
}
</script>
</head>
<body>
<h2>Tutorial: Creating a simple application</h2>

<p>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.</p>

<p>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.</p>

<p>To create a simple "Hello World" application using the CDT, you will perform the following steps:</p>

<h3> Step 1: Creating a project</h3>
<ol>
	<li>Select <b>File &gt; New &gt; Project</b>.</p>
	<p><a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic02.png')">Click here to see an illustration (displayed in a separate window)</a>.</p><br></li>

	<li>Select the type of project to create. For this tutorial, expand the <b>C++</b> folder and select <b>C++ Project</b> and click <b>Next</b>.
	<a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic03a.png')">Click here to see an illustration.</a><br></p>
	<p><br>The <b>C++ Project</b> wizard opens.</p>
	<a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic04.png')">Click here to see an illustration.</a><br></p>
    <p><br>By default, the CDT filters the <b>Toolchain</b> and <b>Project types</b> that it displays in those lists based on the language support for the C++ Project wizard you selected for this tutorial.</p>
    </li><br>
    <li><p>In the <b>Project name</b> field, type a name for the project.</p>
    <br>
    <li><p>From the <b>Project types</b> list, expand <b>Executable</b> and select <b>Hello World C++ Project</b>. This project type provides a simple Hello World application in C++, and the makefile is automatically created by the CDT.</p>
	<br>
    <li><p>Select a required toolchain from the <b>Toolchain</b> list.</p>
    <br>
    <p>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.</p>
    <br>
    <li><p>Click <b>Next</b>.</p>
    <br>
    <p>The Select Configurations window displays a list of configurations based on the project type and toolchain(s) you selected earlier.
    <br>
    <a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic07.png')">Click here to see an illustration.</a></p>
    <br>
    <li><p>Optional: If you want to change the default project settings, click <b>Advanced Settings</b>.</p>
    <br>
    <p>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.</p>
    <p><a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic21.png')">Click here to see an illustration.</a></p>
    <br>
	<li>If you clicked <b>Next</b> at Step 6, you can specify the basic properties for the new project, such as your name, copyright, and source information.</p>
	<p><a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic22.png')">Click here to see an illustration.</a></p>
	<br>
    <li><p>Click <b>Finish</b>.</p>
    <br>
	<li><p>If the <b>C++ perspective</b> 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 <b>Yes</b>.
	<br><p><a href="javascript:void(0)" onClick="newWin('../images/cdt_w_cpp_perspectx.png')">Click here to see an illustration.</a></p>
	<br>
	<p>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.</p>
</ol>

<h3>Step 2: Creating a new file for the project</h3>
<p>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. </p>

<ol>
	<li>Right-click on your project in the Navigator.
	<li>Select <b>New &gt; Source File</b>.
	<p>You should now see the new project in the C/C++ Projects view under the project, and the new file opens in the <b>Editor</b> view.</p>
</ol>  

<h3>Step 3: Enter and step through the code</h3>
<ol>
	<li>Copy the code from the file <a href="javascript:void(0)"
 onclick="newWin('hw_example.htm')" title="here">main.cpp</a>
file that was just created.
<p>
You can double click the <b>main.cpp</b> tab in the <b>Editor</b>
view to expand the view. <br>
<i>Note: Leave a blank line at the end of the code because it is required by some compilers.</i></p>
<p>On the tab in the <b>Editor</b> view, an asterisk character ("*") prefixes the file name. The asterisk indicates that the file has changed but has not been saved.</p>
	<li>Notice that the <b>Outline</b> view has also been populated
with objects created from your code. </p>
<p>If you select an item from the <b>Outline</b> view, the
corresponding text in the editor is highlighted.
<li>Save the main.cpp file by clicking <span
 style="font-weight: bold;">File &gt; Save</span> or pressing <b>CTRL+S</b>.
<li>Build your project by pressing <b>CTRL+B</b>.</p>
<p>You can read through the build messages in the <b>Console</b> view.
The project should build successfully, showing the following message:</p>
<p><tt>Finished building target: HelloWorld.exe</tt></p>
<br>
<p>You will also see the <b>Outline</b> view has also been populated
with objects created from your code. </p>
<p>If you select an item from the <b>Outline</b> view, the
corresponding text in the editor is highlighted.</p></li>
</ol>  

<h3>Step 4: Running the application</h3>
<ol>
	<li>To run your application within the C/C++ Perspective, click <b>Run &gt; Run...</b>
	<li>Select <b>C/C++ Local Application</b>.
	<li>Click <b>'New'</b>.
<li>Click <b>'New'</b>.</p>

<p>A new Run Configuration is created. Its name and path to executable are provided by the project ('HelloWorld' in our case). 

<li>Click <b>'Run'</b>.
</ol>  

<h3>Step 5: Reviewing and interpreting the results in the Console view</h3>
<p>Now, you should now see the Hello World application running in the <b>Console</b> view.  
The <b>Console</b> 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.</p>
<ol>
	<li>Type in your name and press Enter.
	<p>The title bar in the <b>Console</b> view shows you when the program has terminated.</p>

	<li>You can click the other views to see the information that they contain.
</ol> 


<hr>
<img src="../images/ng00_07.gif" ALT="QNX Software Systems Copyright Statement" >
</body>
</html>

Back to the top