carbidecpp22devenv/configuration/org.eclipse.osgi/bundles/309/1/.cp/getting_started/cdt_w_basic.htm
author cawthron
Fri, 04 Dec 2009 10:01:33 -0600
changeset 5 684bf18fdedf
permissions -rw-r--r--
add files for RCL_2_2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     2
<html lang="en">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     3
<head>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     4
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     5
	<title>New CDT Project with generated makefile - Tutorial</title>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     6
	<link rel="stylesheet" type="text/css" href="../help.css">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     7
<script language="JavaScript">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     8
function newWin(url) {
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     9
	window.open(url, 'install_cdt', 'width=900, height=700, menubar=no, toolbar=no, status=no, resizable=yes, location=no, scrollbars=yes');
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    10
}
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    11
</script>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    12
</head>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    13
<body>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    14
<h2>Tutorial: Creating a simple application</h2>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    15
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    16
<p>In this tutorial, you will use the CDT to create a simple 'Hello World' application.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    17
This tutorial describes the process of creating a new C++ project where the build is
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    18
automatically managed by the CDT, and running the program.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    19
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    20
<p>Note: In earlier versions of the CDT, there were two separate project types:
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    21
Managed make (automatically generated a makefile)
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    22
and Standard make (required the user's makefile to build).
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    23
Now with CDT, you now select a project type, and that determines what build system will be used.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    24
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    25
<p>To create a simple "Hello World" application using the CDT, you will perform the following steps:</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    26
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    27
<h3> Step 1: Creating a project</h3>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    28
<ol>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    29
	<li>Select <b>File &gt; New &gt; Project</b>.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    30
	<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>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    31
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    32
	<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>.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    33
	<p><a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic03a.png')">Click here to see an illustration.</a><br></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    34
	<p><br>The <b>C++ Project</b> wizard opens.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    35
	<a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic04.png')">Click here to see an illustration.</a><br></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    36
    <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>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    37
    </li><br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    38
    <li><p>In the <b>Project name</b> field, type a name for the project, such as <b>Hello World</b>.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    39
    <br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    40
    <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>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    41
	<br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    42
    <li><p>Select a required toolchain from the <b>Toolchain</b> list.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    43
    <br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    44
    <p>A toolchain is a set of tools (such as a compiler, linker, and assembler) intended to build your project.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    45
    Additional tools, such as a debugger, can be associated with a toolchain.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    46
    There can be several toolchains available, depending on the compilers installed on your system.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    47
    <br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    48
    <li><p>Click <b>Next</b>.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    49
    <br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    50
    <p>The Select Configurations window displays a list of configurations based on the project type and toolchain(s) you selected earlier.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    51
    <br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    52
    <a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic07.png')">Click here to see an illustration.</a></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    53
    <br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    54
    <li><p>Optional: If you want to change the default project settings, click <b>Advanced Settings</b>.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    55
    <br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    56
    <p>This opens the project properties dialog for your new project allowing you change any of the project specific settings,
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    57
    such as includes paths, compiler options, and libraries.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    58
    <p><a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic21.png')">Click here to see an illustration.</a></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    59
    <br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    60
	<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>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    61
	<p><a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic22.png')">Click here to see an illustration.</a></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    62
	<br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    63
    <li><p>Click <b>Finish</b>.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    64
    <br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    65
	<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>.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    66
	<br><p><a href="javascript:void(0)" onClick="newWin('../images/cdt_w_cpp_perspectx.png')">Click here to see an illustration.</a></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    67
	<br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    68
	<p>A project is created with the default settings and a full set of configurations based on the project type and toolchain you selected.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    69
	You should now see the new project in C/C++ Projects view.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    70
	<p><a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic12.png')">Click here to see an illustration.</a></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    71
	<br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    72
</ol>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    73
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    74
<h3>Step 2: Reviewing the code and building the project</h3>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    75
<ol>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    76
	<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>. 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    77
	<p>Note that the file may be within a folder inside the project, e.g. the "src" folder.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    78
	<p>This file opens in a default editor. It contains C++ template code for the Hello World example project you selected earlier.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    79
	<br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    80
	<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
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    81
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>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    82
</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    83
<li>Optional: You can type additional code in this file, and then save the changes by clicking <span
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    84
 style="font-weight: bold;">File &gt; Save</span>, or pressing <b>CTRL+S</b>.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    85
 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    86
 <p><br>Next, you will need to build your project before you can run it.</p><br></li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    87
<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>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    88
<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>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    89
<li>Read through the build messages in the <b>Console</b> view.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    90
The project should build successfully.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    91
<br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    92
<p>You will also see the <b>Outline</b> view has also been populated
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    93
with objects created from your code. If you select an item from the <b>Outline</b> view, the
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    94
corresponding text in the editor is highlighted.</p><br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    95
</ol>  
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    96
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    97
<h3>Step 3: Running the application</h3>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    98
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    99
<p>To run your application:</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   100
<ol>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   101
	<li>Within the C/C++ Perspective, click <b>Run &gt; Run Configurations...</b>.<p><br></p></li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   102
	<li>Select <b>C/C++ Application</b>.<p><br></p></li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   103
    <li>Click <b>New</b>.<p><br></p></li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   104
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   105
	<p>A new Run Configuration is created. Its name and path to the executable are provided by the project ('Hello World' in our case). 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   106
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   107
	<li>Click <b>Run</b>.<p><br></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   108
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   109
<p>Now, you should see the Hello World application running in the <b>Console</b> view.  
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   110
The <b>Console</b> also shows which application is running in a title bar.</p><br></li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   111
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   112
	<li>You can click the other views to see the information that they contain.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   113
</ol> 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   114
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   115
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   116
<hr>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   117
<img src="../images/ng00_07.gif" ALT="QNX Software Systems Copyright Statement" >
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   118
</body>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
   119
</html>