Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Eclipse C/C++ Developer Guide
Previous Page Home Next Page

Tutorial: Creating a simple application

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.

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.

To create a simple "Hello World" application using the CDT, you will perform the following steps:

Step 1: Creating a project

  1. Select File > New > Project.

    Click here to see an illustration (displayed in a separate window).

  2. Select the type of project to create. For this tutorial, expand the C++ folder and select C++ Project and click Next.

    Click here to see an illustration.

    The C++ Project wizard opens.

    Click here to see an illustration.

    By default, the CDT filters the Toolchain and Project types that it displays in those lists based on the language support for the C++ Project wizard you selected for this tutorial.

  3. In the Project name field, type a name for the project, such as Hello World.

  4. From the Project types list, expand Executable and select Hello World C++ Project. This project type provides a simple Hello World application in C++, and the makefile is automatically created by the CDT.

  5. Select a required toolchain from the Toolchain list.

    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.

  6. Click Next.

    The Select Configurations window displays a list of configurations based on the project type and toolchain(s) you selected earlier.
    Click here to see an illustration.

  7. Optional: If you want to change the default project settings, click Advanced Settings.

    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.

    Click here to see an illustration.

  8. If you clicked Next at Step 6, you can specify the basic properties for the new project, such as your name, copyright, and source information.

    Click here to see an illustration.

  9. Click Finish.

  10. If the C++ perspective 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 Yes.

    Click here to see an illustration.

    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.

    Click here to see an illustration.

Step 2: Reviewing the code and building the project

  1. From the Project Explorer in the C++ Projects View, double-click the .cpp file that was created for your project, for example, Hello World.cpp.

    Note that the file may be within a folder inside the project, e.g. the "src" folder.

    This file opens in a default editor. It contains C++ template code for the Hello World example project you selected earlier.

    Note: You can specify a different editor, and add or modify existing code templates in Window > Preferences.

    In addition, the Outline view has also been populated with objects created from your code.

    Click here to see an illustration.

  2. Optional: You can type additional code in this file, and then save the changes by clicking File > Save, or pressing CTRL+S.

    Next, you will need to build your project before you can run it.

  3. Build your project by pressing CTRL+B, or select the project from the Project Explorer tab in the C++ Projects view and select File > Build Project.

    Note: If a build generates any errors or warnings, you can see those in the Problems view. If you encounter difficulty, see the topics Building C/C++ projects and Before you begin

  4. Read through the build messages in the Console view. The project should build successfully.

    You will also see the Outline view has also been populated with objects created from your code. If you select an item from the Outline view, the corresponding text in the editor is highlighted.

Step 3: Running the application

To run your application:

  1. Within the C/C++ Perspective, click Run > Run Configurations....

  2. Select C/C++ Application.

  3. Click New.

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

  5. Click Run.

    Now, you should see the Hello World application running in the Console view. The Console also shows which application is running in a title bar.

  6. You can click the other views to see the information that they contain.

QNX Software Systems Copyright Statement

  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire