How to Configure Eclipse for C/C++

Rose-Hulman Institute of Technology –
Computer Science & Software Engineering


Once you have installed Eclipse, follow these directions to configure it to develop code in C/C++.

Make sure all required software is installed

  1. Eclipse 3.7

    The 2011-2012 freshmen laptops came with the latest version installed.

    1. If you need to install it, follow these instructions.
  2. MinGW

    All freshmen laptops since 2007 came with MinGW.

    1. If you need to install it, follow these instructions.

Install the C/C++ Development Tools (CDT) for Eclipse

Except where noted you can simply accept the defaults.
Eclipse 3.7/Indigo, 3.6/Helios, and 3.5/Galileo
  1. Log in to your regular user account
  2. Start Eclipse.
  3. Select Help → Install New Software...
  4. Before going further, check that you do not actually have the C/C++ plug-in installed. While in the Install New Software dialog,  click on "What is already installed?") If so, you may skip ahead to Writing Your First Program below.
  5. Carefully type this url:                           in the Work with:   field. After several seconds, two items will appear. Check both items.  
  6. Click Next and OK to continue installing CDT. Accept trust certificates as needed and continue despite any security warnings that may pop up.
  7. Answer "yes" to the "restart Eclipse?" question.
  8. When Eclipse next opens you will see an Overview screen. If you want to find out more about any part of Eclipse, select that category; otherwise click on the arrow icon to proceed to workbench.

Installing Eclipse Preferences for C/C++

  1. Download the Eclipse Preferences

      If you have already installed the Eclipse preferences for Python, you can skip to "Writing your first C program"

    1. Unzip this Preferences for csse120 file, placing its sole unzipped file (EclipsePreference-2011-06.epf)  in any convenient file.

  2. Import the Preferences
    1. Launch Eclipse.

      1. If Eclipse offers to Select a Workspace, browse to C:\EclipseWorkspace\csse120.

      2. Otherwise, choose File → Switch Workspace → Other, and click Next.

    2. Now you are ready to set the preferences for the workspace:

      1. Choose File → Import

      2. In the Import dialog box, select General → Preferences and click Next.

      3. When the Import Preferences dialog opens, select Browse and find the EclipsePreferences-2011-06.epf file that you unzipped and saved above.

      4. Back in the Import Preferences dialog, check Import All, then select Finish.

      5. As before, if the Subclipse Usage dialog makes an appearance, uncheck the box and continue.

      6. Confirm that the installation did not leave behind an unintended footprint by checking if there is:

        1. random .eclipse folder anywhere, possibly in the folder immediately above My Documents.

        2. Any extra users (for example, the installer), in C:\Users

        3. Extra Eclipse workspaces anywhere except for the folders inside C:\EclipseWorkspaces.

Writing Your First C Program

You should be able to use the same workspace for C as you did for Python or Java, i.e., csse 120.

  1. Create a new project
    1. Go to Window → Open perspective → Other, select C/C++, and click OK.
    2. Go to File → New → C Project, and choose a name for the project (for example, Greeting).
    3. In the Project Types pane, expand Executable and select Hello World ANSI C Project
    4. Click Finish to accept all defaults.
  2. Populate a new file containing the main function.
    1. Expand the new project you've made. In the src folder, find and open the file Greeting.c.
    2. The file should already contain some comments, plus some code to print a simple message.
  3. Build, compile, and run the project.
    1. Right-click the project (not Greeting.c) and select Run As → Local C/C++ Application.
    2. If asked, choose the gdb Debugger.
    3. Look at the Console at the bottom of your screen and you will see the message the program told the computer to print.

      Congratulations! You have written your first program with C.

  4. Configure this workspace
    1. Add line numbers by right-clicking in the margin to the left of the code window and click on Show Line Numbers.

Configuring C/C++ OpenGL Projects (for CSSE325, CSSE351, and CSSE451)

  1. Get the GLUT installation
    1. Download and unzip this version of GLUT.
    2. Copy the files in include\gl, include\mui, and lib to the corresponding places in C:\Program Files\MinGW. Be sure to overwrite files as necessary.
    3. Copy glut32.dll to C:\WINDOWS\System32.
  2. Point your Eclipse project to the glu, glut, and OpenGL libraries.
    1. You must do this for each graphics project you create, before you build it!
    2. Select Project → Properties.
    3. Double click C/C++ Build → Settings in the list on the left.
    4. In the Tool Settings tab, select MinGW C Linker → Libraries (in Eclipse 3.5 and older, choose GCC C++ Linker → Libraries).
    5. One at a time, add glut32, glu32 and opengl32 to the Libraries pane.
    6. Build your program as usual.