Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7914bc4981a0f18d329c3a347378419c1555ab2a (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
<!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, such as <b>Hello World</b>.</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>
	<p><a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic12.png')">Click here to see an illustration.</a></p>
	<br>
</ol>

<h3>Step 2: Reviewing the code and building the project</h3>
<ol>
	<li>From the Project Explorer in the C++ Projects View, double-click the .cpp file that was created for your project, for example, <tt>Hello World.cpp</tt>. 
	<p>This file opens in a default editor. It contains C++ template code for the Hello World example project you selected earlier.</p>
	<br>
	<p><b>Note:</b> You can specify a different editor, and add or modify existing code templates in <b>Window &gt; Preferences</b>.</p><p>In addition, the <b>Outline</b> view has also been populated
with objects created from your code.</p> <p><a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic13.png')">Click here to see an illustration.</a></p>
</li>
<li>Optional: You can type additional code in this file, and then save the changes by clicking <span
 style="font-weight: bold;">File &gt; Save</span>, or pressing <b>CTRL+S</b>.
 
 <p><br>Next, you will need to build your project before you can run it.</p><br></li>
<li>Build your project by pressing <b>CTRL+B</b>, or select the project from the Project Explorer tab in the C++ Projects view and select <b>File &gt; Build Project</b>.</p>
<p><br><b>Note:</b> If a build generates any errors or warnings, you can see those in the Problems view. If you encounter difficulty, see the topics <a href="../concepts/cdt_c_build_over.htm">Building C/C++ projects</a> and <a href="../concepts/cdt_c_before_you_begin.htm">Before you begin</a><br>.</p></li>
<li>Read through the build messages in the <b>Console</b> view.
The project should build successfully.</p>
<br>
<p>You will also see the <b>Outline</b> view has also been populated
with objects created from your code. If you select an item from the <b>Outline</b> view, the
corresponding text in the editor is highlighted.</p><br>
</ol>  

<h3>Step 3: Running the application</h3>

<p>To run your application:</p>
<ol>
	<li>Within the C/C++ Perspective, click <b>Run &gt; Run</b>.<p><br></p></li>
	<li>Select <b>C/C++ Local Application</b>.<p><br></p></li>
    <li>Click <b>New</b>.<p><br></p></li>

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

	<li>Click <b>Run</b>.<p><br></p>

<p>Now, you should 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.</p><br></li>

	<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