How to Configure Eclipse for C/C++

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

Overview

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.4 (3.2 also works)

    The 2008-2009 freshmen laptops came with the latest version.

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

    The 2008-2009 freshmen laptops 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.4
  1. Log in to your regular user account
  2. Start Eclipse.
  3. Select Help → Software Updates...
  4. Switch to the "Available Software" tab.
  5. Expand "Ganymede" and check "C and C++ Development." Click Install...
  6. Click Next, accept the License agreement and click Finish.
  7. Answer "yes" to the "restart Eclipse?" question.
Eclipse 3.2
  1. Start Eclipse.
  2. Select Help > Software Updates > Find and Install.
  3. Select Search for new features to install.  Click Next.
  4. Check the "Callisto Discovery Site"; uncheck the other sites. Click Finish.
  5. Select a mirror site.  Indiana University is a good choice.  Click OK.
  6. Expand the "Callisto Discovery Site" and the C/C++ Development Tools. Check Eclipse C/C++ Development Tools. Click Next. Note: If you already have the C/C++ Development Tools installed, then you won't find C/C++ Development Tools listed. In that case, go on to the next section on Writing Your First C Program.
  7. Accept the License agreement and click Next, then click Finish.
  8. When the Verification dialog comes up, click Install All.
  9. Answer "yes" to the "restart Eclipse?" question.

Writing Your First C Program

  1. Create a new Eclipse workspace for your C programs
    1. Quit Eclipse
    2. In Windows, create a new folder to use as your Eclipse workspace for C programs.
    3. Launch Eclipse
    4. When Eclipse starts and asks you to select a workspace, click Browse and browse to the folder you created. Close the Browser and click OK in the Workspace Launcher dialog.
    5. Click on the Workbench arrow.
  2. 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.
  3. 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.
  4. 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.

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 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.
    5. One at a time, add glut32, glu32 and opengl32 to the Libraries pane.
    6. Build your program as usual.