Tutorial of Eclipse C++ for ENGI 1020

In this tutorial, we will use the Eclipse C/C++ Development Toolkit (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.

When working in the lab EN-3000/3029, Eclipse-C++ can be started through the Start->All Programs->Eclipse-C++->Eclipse-C++. Then the following window will show up. You need to specify the workspace you want to set up. Here you may want to assign a directory under your "My Documents" folder as your workspace, e.g., C:\Documents and Settings\lihong\My Documents\workspace (please change "lihong" to your own login user name). 

Then click Ok. By default, a Welcome window in C/C++ -Eclipse Platform pops up. If you minimize the Welcome window, the C/C++ -Eclipse Platform should look like:


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.

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


    The C++ Project wizard opens.

    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 HelloWorld.
  4. From the Project types list, just select Executable as your target project type. Then a blank project will be created.
  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 may be several toolchains available, depending on the compilers installed on your system. In our lab, only MinGW GCC is available. On your own computer for this course use MinGW GCC on Windows or MACOSX GCC on Mac OS X.
  6. Click Next.
    The Select Configurations window displays a list of configurations based on the project type and toolchain(s) you selected earlier.


  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.

  8. Click Finish. 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 created project in Project Explorer view as shown below.


Step 2: Creating new source files and building the project

  1. You can create new source files (including .cpp files and .h files) into your created project. By clicking File->New->Source File, you will see the following pop-up window. Type the name of your new source file, for instance HelloWorld.cpp, into the block of Source File. Then click Finish.

    You will see a blank HelloWorld.cpp is created. From the Project Explorer in the C++ Projects View, double-click this .cpp file. Then type the following code into the blank editor.

    * Memorial University of Newfoundland
    * Engineering 1020 Structured Programming, Term B
    * Assignment 0 (Section 1)
    * Author: Lihong Zhang (engr.-user: lihong)
    * Date: 2008.01.14
    * HelloWorld.cpp -- a single main .cpp file outputing "Hello World!"
    * ***********************************************************************/

    #include <iostream>
    using namespace std;

    int main() {
        cout << "Hello World!" << endl; // prints Hello World!
        return 0;

    You should get the CDT something like below:

  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. Alternatively, you can put your mouse on the title of your project (i.e., "HelloWorld") in the Project Explorer view. Right click and choose Build Configurations->Build->All. Then the build process should start.

    Note: If a build generates any errors or warnings, you can see those in the Problems view.

  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

Within the C/C++ Perspective, click Run > Run. The following window pops up:

 Select one of the binary files HellowWorld.exe, and then click OK. Now, you should see the HelloWorld application running in the Console view as shown below. The Console also shows which application is running in a title bar.

Note: after each of your labs, you should always copy your project directory to your M: Drive for the archive purpose. For instance, in this lab you can find you project directory at C:\Documents and Settings\lihong\My Documents\workspace\HelloWorld, and your created .cpp file at C:\Documents and Settings\lihong\My Documents\workspace\HelloWorld\HelloWorld.cpp  (please change "lihong" to your own login user name). Normally only one .cpp file is required to be submitted via web submit.


Back to 1020-lab homepage