How to Install Eclipse for C++ Development

Installation on Windows:

You will need:
  1. MinGW (which includes the gcc compiler. Note that the video provides another way to get the compiler that you might find easier)
  2. The Java JRE (yes you need Java to write C++ code using Eclipse!)
  3. Eclipse package for C++ developers on Windows.
Watch this video for step-by-step instructions on downloading and installing the above
Alternately, watch this video for step-by-step instructions on downloading and installing the above on Windows 10.

Note that, depending on the video, it might not contain instructions for setting up your PATH, which you will likely need to do as part of installation.

  1. Right-click on your "My Computer" icon and select "Properties".
  2. Click on the "Advanced" tab, then on the "Environment Variables" button.
  3. You should be presented with a dialog box with two text boxes. The top box shows your user settings. The PATH entry in this box is the one you want to modify. Note that the bottom text box allows you to change the system PATH variable. You should not alter the system path variable in any manner, or you will cause all sorts of problems for you and your computer!
  4. Click on the PATH entry in the TOP box, then click on the "Edit" button
  5. Scroll to the end of the string and at the end add
  6. press OK -> OK -> OK and you are done.

NOTE: Substitute <installation-directory> with the FULL absolute path name of the installation target directory you chose (e.g. C:\MinGW);

Installation on the Mac:

You will need:
  • Xcode with command line tools from the Apple Developer site
  • The Java JRE (yes you need Java to write C++ code using Eclipse!) 
  • Eclipse package for C++ developers on the Mac. Alternately, this package if you are having trouble installing the new Eclipse Oxygen.

Read this tutorial for step-by-step instructions on downloading and installing the above.

How to Run Your Code:

  • Open up Eclipse by double clicking on the icon
  • Go to File->New->C++ Project
  • When you reach the next screen (see below), complete the following steps:
  1. Select "Hello World C++ Project"
  2. Select the GCC compiler (note if you are on windows it will not say MacOSX. Instead there will be a windows option)
  3. Give your project a name. In my example, I named it MyProject
  4. Click the Finish button

  • The name of your project should now appear in project explorer on the left.
  • Right click on the name of the project and select Build Project from the drop down menu as shown.

  • Important Note: If you do not follow this step, you will get errors when you try to compile and run.
  • Once you have built the project, try to compile and run and make sure "!!!Hello World!!!" appears at the bottom of your screen.
  • To add files to this project, click on the name of the project so it is highlighted.
  • Then, go to File->New->Header File or File -> New -> Source File (depending on your purposes)

  • Follow the prompts, give your file a name and then the file name should appear in the document tree under the project navigator on on the left.

  • Go to Source->Format
  • Alternately, CNTRL + F or CMD + F

Trouble Shooting Guide

1. If Eclipse is not recognizing the header file when you include it in the source file, try the following:
  • Right click on the project and select properties.
  • Select C/C++ General -> Path and Symbols.
  • Select Includes tab.
  • In Languages list, select 'GNU C++'.
  • Press 'Add...' button and add the directory for the include files.
  • Close Properties window and rebuild. You should see new path being used as -I in build process

2. If you get "Launch Failed. Binary Not Found", try the following

Verify that you selected the GCC compiler NOT the Cross Compiler.
You might want to delete your project and try again, making sure you have selected the correct compiler again.

Once you are certain, right click your project and select "Build" from the drop down menu.
Note that you want to create the binaries before you add any code to the project to make sure it is working.

Once you build, then compile and run and you should see Hello World displayed.
Now, you can begin adding code to your project.

3. If Eclipse doesn't create a .exe file (program builds but doesn't run)
  • Run->Run Configurations->Environment
  • Now add the path to the compiler under Environment
4. What to do if your project explorer (sidebar with all of your projects and files) is hidden
  • window->show view->project explorer
5. If you get the error message "program file not found" and you had dragged and dropped your files into the project folder, you can use the fix described here

6. If you run into any other problems, please feel free to see me in office hours!