CPS 108: Installation Guide for Eclipse and CDT

We will be using the Eclipse integrated development environment (IDE) with Duke's Ambient plugin for our projects in CPS 108. This guide contains the steps you will need to follow to install Eclipse on your own PC.

Eclipse is only an IDE; it does not contain any compilers. Since we will be writing both Java and C++ projects during this course, we will need to install compilers for both of these languages, as well as the C/C++ Development Tools (CDT) plugin for Eclipse. For C++, we will use MinGW and MSYS, which allow us to run some GNU tools (including a C++ compiler) on Windows.

Mac and Linux users should NOT NEED to install the C++ compiler or the Unix tools. Mac users will need to make sure that

Note that for this course, we'll be using the latest versions of Eclipse (3.1) and the Java Development Kit (5.0 update 4). If you've already installed a previous version of Java or Eclipse, you'll still need to install the newer versions.

To install Eclipse for Java and C++, follow these steps. If you have any problems, please post a message on the course discussion board.

1: Install MinGW and MSYS

  1. Download MinGW-4.1.1.exe and MSYS-1.0.10.exe to your PC.
  2. Run the MinGW-4.1.1.exe file to install MinGW. The default options should be fine. Note that you'll need an active internet connection for the installer to work.
  3. After installing MinGW, run MSYS-1.0.10.exe to install MSYS. Again, the default options should be fine. At the end of the installation, it will ask if it can run a "post install process" to make MSYS work better with MinGW. Answer yes ("y"). It will then ask if you have MinGW installed. Answer yes again, and then type the location of the MinGW installation. If you followed the default options, you can enter "c:/MinGW" (note that here, the installer asks for a forward slash instead of a backslash as a path separator).
  4. We now need to add the location of the MinGW and MSYS executables to the Path environment variable so that Eclipse can find the compiler. To do this:
    1. Right click on the "My Computer" icon in the start menu and choose "properties".
    2. Click on the "Advanced" tab, and then on the "Environment Variables" button.
    3. Under "System variables", scroll down until you find the "Path" variable. Click on "Path", and then choose the "Edit" button.
    4. Add the following directories to the end of the path list: "c:\MinGW\bin" and "c:\MSYS\1.0\bin" (or the directories you chose to install to, if you didn't use the default options). Make sure each directory is separated by a semicolon.
    5. To test that the path has been set up correctly, open a command window (Start -> Run -> "cmd") and type "make". The output should read

      make: *** No targets specified and no makefile found. Stop.

      If the make command cannot be found, then there is an error in your Path variable.

2: Install Java, Eclipse, and Ambient

A detailed guide to installing Java, Eclipse, and the Ambient plugin can be found here. To summarize, you'll first install the latest Java Development Kit (5.0 Update 4), install Eclipse 3.1 (by simply unzipping the file), and then install the latest version of Ambient with Eclipse's update manager. You may also wish to make a shortcut to the Eclipse executable for your desktop or start menu.

3: Install the CDT

We will install the CDT using Eclipse's update manager, in the same way we installed Ambient.

  1. Start Eclipse.
  2. Go to Help -> Software Updates -> Find and Install....
  3. Select "Search for new features to install" and click next.
  4. Click on "New Remote Site".
  5. For the name field, type "CDT". For the URL, type "http://download.eclipse.org/tools/cdt/releases/eclipse3.1". Click "Ok", and then click "Finished".
  6. Eclipse will now ask you which features you'd like to install. Check the box next to "CDT" and click "Next".
  7. Accept the license agreement and click "Next", and then click "Finished". The CDT will be downloaded and installed. You should restart the workbench when prompted.

4: Testing the Installation

Now that everything is installed, it's a good idea to verify that we are able to compile and run both Java and C++ programs.

Testing Java

  1. Create a new Java project. Go to File -> New and select "Java Project".
  2. Name the project "JavaTest" and click "Finished".
  3. The JavaTest project should appear in the package explorer (on the left side of the workbench). Right-click on "JavaTest" and select New -> Class.
  4. Name the class "HelloWorld", and check "public static void main(String[] args)" to create a main method stub. Click "Finish".
  5. Add the line "System.out.println("Hello World!");" to the main method.
  6. Run the program by choosing Ambient -> Ambient Run -> Run Application. If everything was installed correctly, and there are no errors, the console should appear at the bottom of the workbench with the words "Hello World!" printed.

Testing C++

  1. Create a new C++ project. Go to File -> New and under the C++ folder, choose "Managed Make C++ Project". Click "Next".
  2. Name the project "CPlusPlusTest" and choose "Finish".
  3. Eclipse will ask if you'd like to switch to the C++ perspective. Choose "yes". A perspective is just a preset arrangement of the workbench tools that corresponds to the particular language we're using.
  4. The CDT documentation suggests that the "Build Automatically" option is turned off for C++ projects. This will prevent the entire project (including headers and makefiles) from being rebuilt each time a file is saved. To do so, go to the project menu and deselect "Build Automatically".
  5. In the C/C++ project explorer (on the left side of the workbench), right-click on CPlusPlusTest and choose New -> File. Name the file "HelloWorld.cpp" and click "Finish".
  6. Type or paste the following code into the HelloWorld.cpp file and save it:

    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        cout << "Hello World!" << endl;
        return 0;
    }
  7. In the project explorer, Right-click on the CPlusPlusTest and choose "Build Project". If everything was installed correctly, and there are no errors, a folder named "Binaries" should appear under CPlusPlusTest.
  8. To run the program, expand the Binaries folder, and you should see CPlusPlusTest.exe. Right-click on this file and choose Run As -> Run Local C/C++ Application. The console should appear at the bottom of the workbench with the words "Hello World!"

Christopher J. La Pilla
Last update: 8/23/05