1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
cdt/doc/org.eclipse.cdt.doc.user/getting_started/cdt_w_basic.htm
2007-06-21 02:59:37 +00:00

124 lines
No EOL
6.7 KiB
HTML

<!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=750, 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><br><a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic20.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>.
<p><br>The <b>C++ Project</b> wizard opens. <a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic19.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 currently display in those lists are based on the language support for the C++ Project wizard you selected for this tutorial.
<li>In the <b>Project name</b> field, type a name for the project.
<li>From the <b>Project types</b> list, expand <b>Executable</b> and select <b>Hello World C++ Example</b>. This project type provides a simple Hello World application in C++, and the makefile is automatically created by the CDT.
<li>Select a required toolchain from the <b>Toolchain</b> list.
<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.<br>
There can be several toolchains available, depending on the compilers installed on your system.
</p>
<li>Optional: If you want to change these default settings, click <b>Advanced Settings</b> at Step 10instead of clicking <b>Finish</b>.
<p>If the <b>C++ perspective</b> is not currectly 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><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.</p>
<li>If you clicked <b>Next</b> at Step 7, you can specify the basic properties for the new project, such as your name, copyright, and source information.</p><br>
<p><a href="javascript:void(0)" onClick="newWin('../images/cdt_w_basic15.png')">Click here to see an illustration.</a></p><br>
<li>Click <b>Next</b>.
<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_basic14.png')">Click here to see an illustration.</a></p><br>
<li>Click <b>Finish</b>.
<p>You should now see the new project in C/C++ Projects view.</p>
<p>If C/C++ perspective was not set as current before, it will be selected now.</p>
<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>