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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<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="../book.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>
<h1 role="main">Tutorial: Creating a simple application</h1>
<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, and running the program.</p>
<p><strong>NOTE</strong>: 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 just select a project type, and that determines what build system to use.</p>
<p>To create a simple "Hello World" application using CDT, perform the following general steps:</p>
<ol>
<li><a href="#cdt_create">Creating a project</a></li>
<li><a href="#cdt_build">Reviewing the code and building the project</a></li>
<li><a href="#cdt_running">Running the application</a></li>
</ol>
<hr>
<h2> Step 1: <a name="cdt_create"></a>Creating a project</h2>
<ol>
<li>Select <strong>File > New > Project</strong>.<br>
<br>
<img src="../images/cdt_w_basic02.png" alt="Select File > New > Project menu option" width="591" height="183">
<p><br>
</p>
</li>
<li>Select the type of project to create. For this tutorial, expand the <strong>C++</strong> folder and select <strong>C++ Project</strong> and click <strong>Next</strong>.<br>
<br>
<img src="../images/cdt_w_basic03a.png" alt="Select project type" width="525" height="500"><br>
<br>
</li>
<li>
<p>The <strong>C++ Project</strong> wizard opens.<br>
</p>
<p><img src="../images/cdt_w_basic04.png" alt="C++ project wizard" width="525" height="576"><br>
<br>By default, the CDT filters the <strong>Toolchain</strong> and <strong>Project types</strong> that it displays in those lists based on the language support for the C++ Project wizard you selected for this tutorial.</p>
<br>
<ol style="list-style-type: lower-alpha;">
<li>In the <strong>Project name</strong> field, type a name for the project, such as <strong>HelloWorld</strong>.
<p><br>
</p>
</li>
<li>From the <strong>Project type</strong> list, expand <strong>Executable</strong> and select <strong>Hello World C++ Project</strong>. This project type provides a simple Hello World application in C++, and the makefile is automatically created by the CDT.
<p><br>
</p>
</li>
<li>Select a required toolchain from the <strong>Toolchain</strong> list.
<p><br>
</p>
<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>
<p><br>
</p>
</li>
<li>Click <strong>Next</strong>. </li>
</ol>
<br>
</li>
<li>Specify the <strong>Basic Properties</strong> for the new project, such as your author, copyright, and source information, then click <strong>Next</strong>.<br>
<br>
<img src="../images/cdt_w_basic06a.png" alt="Basic properties of a project" width="525" height="576"><br>
<br>
</li>
<li>
<p>The <strong>Select Configurations</strong> page displays a list of configurations based on the project type and toolchain(s) selected earlier. <br>
<br>
<img src="../images/cdt_w_basic07.png" alt="Select configurations page" width="525" height="576"><br>
<br>
<strong>OPTIONAL</strong>: If you want to change the default project settings, click <strong>Advanced Setting</strong> to open the <a href="../reference/cdt_u_prop_all.htm">Project Properties</a> dialog for your new project allowing you change any of the project specific settings,
such as includes paths, compiler options, and libraries.<br>
<br>
</p></li>
<li><p>Click <strong>Finish</strong>.<br>
</p></li>
</ol>
<p><strong>NOTE</strong> If the <strong>C++ perspective</strong> 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 <strong>Yes</strong>.<br>
</p>
<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 <a href="../reference/cdt_u_project_explorer_view.htm">Project Explorer</a> view.</p>
<p> <img src="../images/cdt_w_basic12.png" alt="New project displayed in the Project Explorer view" width="423" height="283"></p>
<br>
<hr>
<br>
<h2>Step 2: <a name="cdt_build" id="cdt_build"></a>Reviewing the code and building the project</h2>
<ol>
<li>From the <strong>Project Explorer</strong> view, double-click the .cpp file created for your project, for example, <span class="typewriter">HelloWorld.cpp</span>. You'll find it within the project "<span class="typewriter">src</span>" folder.<br>
<br>
<p>This file opens in a default editor. It contains C++ template code for the Hello World example project you selected earlier. In addition, the <a href="../reference/cdt_u_outline_view.htm">Outline</a> view has also been populated
with objects created from your code.<br>
<br>
<img src="../images/cdt_w_basic13.png" alt="C Editor with Outline view" width="731" height="333"><br>
<br>
<strong>NOTE:</strong> You can specify a different editor, and add or modify existing code templates in <strong>Window > Preferences</strong>.<br>
<br>
<strong>OPTIONAL</strong>: You can type additional code in this file, and then save the changes by clicking <span
style="font-weight: bold;">File > Save</span>, or pressing <strong>CTRL+S</strong>.<br>
<br>
Next, you will need to build your project before you can run it.<br>
<br>
</p>
</li>
<li>Build your project by pressing <strong>CTRL+B</strong>, or select the project in the <strong>Project Explorer</strong> view and select <strong>File > Build Project</strong>.
</p>
<p><br>
<strong>NOTE:</strong> If a build generates any errors or warnings, you can see those in the <a href="../reference/cdt_u_problems_view.htm">Problems</a> 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 <a href="../reference/cdt_u_console_view.htm">Console</a> view.
The project should build successfully.</p>
<br>
<br>
<p>You will also see the <strong>Outline</strong> view has also been populated
with objects created from your code. If you select an item from the <strong>Outline</strong> view, the
corresponding text in the editor is highlighted.</p></li>
</ol>
<hr>
<br>
<h2>Step 3: <a name="cdt_running" id="cdt_running"></a>Running the application</h2>
<p>To run your application:</p>
<ol>
<li>Within the C/C++ Perspective, click <strong>Run > Run Configurations...</strong>.<p><br></p></li>
<li>Select <strong>C/C++ Application</strong>.<p><br></p></li>
<li>Click <strong>New</strong>.<br>
<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>
<li>Click <strong>Run</strong>.<p><br></p>
<p>Now, you should see the Hello World application running in the <strong>Console</strong> view.
The <strong>Console</strong> 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.</li>
</ol>
<hr>
<img src="../images/ng00_07.gif" ALT="QNX Software Systems Copyright Statement" >
</body>
</html>
|