<!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, and running the program.</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). Now with CDT, 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 <strong>File > New > Project</strong>.</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 <strong>C++</strong> folder and select <strong>C++ Project</strong> and click <strong>Next</strong>. <p><a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic03a.png')">Click here to see an illustration.</a><br></p> <p><br>The <strong>C++ Project</strong> 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 <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> </li><br> <li><p>In the <strong>Project name</strong> field, type a name for the project, such as <strong>Hello World</strong>.</p> <br> <li><p>From the <strong>Project types</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> <li><p>Select a required toolchain from the <strong>Toolchain</strong> 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 <strong>Next</strong>.</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 <strong>Advanced Settings</strong>.</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 <strong>Next</strong> 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 <strong>Finish</strong>.</p> <br> <li><p>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><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, <span class="typewriter">Hello World.cpp</span>. <p>Note that the file may be within a folder inside the project, e.g. the "src" folder.</p> <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><strong>Note:</strong> You can specify a different editor, and add or modify existing code templates in <strong>Window > Preferences</strong>.</p><p>In addition, the <strong>Outline</strong> 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 > Save</span>, or pressing <strong>CTRL+S</strong>. <p><br>Next, you will need to build your project before you can run it.</p><br></li> <li>Build your project by pressing <strong>CTRL+B</strong>, or select the project from the Project Explorer tab in the C++ Projects 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 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 <strong>Console</strong> view. The project should build successfully.</p> <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><br> </ol> <h3>Step 3: Running the application</h3> <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>.<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 <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. </ol> <hr> <img src="../images/ng00_07.gif" ALT="QNX Software Systems Copyright Statement" > </body> </html>