Eclipse/C++ Downloading/Installing, and Testing Instructions


You may want to print these instructions before proceeding, so that you can refer to them while downloading and installing. Or, just keep this document in your browser. You should read each step completely before performing the action that it describes. This document shows information as of Summer 2015.


Downloading/Installing

The following instructions were composed for downloading the most up-to-date version of Java, Eclipse, and C++.

Xcode Command Line Tools and Homebrew

  1. If you have not already installed the command line tools for Xcode, install them first as described below.

    For most (up to date) version of Mac OS X, open a terminal window and type or copy/paste the following command xcode-select --install. If that succeeds, go to the next step; if it fails, follow the Mac Xcode Command Line Tools installation instructions.

  2. If you have not already installed Homebrew and Homebrew Cask, install them first as described below.

    1. To install Homebrew open a terminal window and type or copy/paste the following command ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" into the window.

      The following will appear in your terminal window; the sections showing The following directories... may not print.

    2. Press return.
      Enter your (system administrator) password when prompted

      The following will appear in your terminal window.

    3. Type or copy/paste the following command brew install caskroom/cask/brew-cask into the terminal window and press return. The following will appear in your terminal window.

      If this fails, showing

      ensure that you followed Step 1 above, and have successfully installed the command line tools for Xcode.

Java, Eclipse, C++

  1. To install Java and Eclipse type or copy/paste the following command brew cask install java eclipse-cpp into the terminal window and press return. The following will appear in your terminal window.

  2. Enter your password and press return. As Java downloads, it progress will be tracked in the terminal window; it is large and might take a few minutes. Eventually the following will appear in the terminal window.

    It will then continue with the eclipse-cpp download. Again, its progress will be tracked in the terminal window; it is even larger than Java,and might take tens of minutes. Eventually the following will appear in the terminal window.

  3. Notice that Eclipse has been installed in the /opt/homebrew-cask/Caskroom/eclipse-cpp/4.5 directory. Move Eclipse.app into the Applications folder and put it on the Doc for simple access.

  4. To install GCC C++, type or copy/paste the following command brew install gcc into the terminal window and press return. The following will appear in your terminal window.

    It will perform a series of download, some short, some longer (taking minutes).


    Eclipse Verification

    In this section we will Eclipse/C++ is working correctly.

    1. Double-click the Eclipse icon on the Dock that you just created above. The following splash screen will appear

      and then a Workspace Launcher pop-up window will appear.

      In the Workspace text box, your login name should appear between /users and /Documents\workspace, instead of my name, richardepattis.

      Leave unchecked the Use this as the default and do not ask again box. Although you will use this same workspace for the entire quarter (checking projects in and out of it), it is best to see this Workspace Launcher pop-up window each time you start Eclipse, to remind you where your workspace is located.

    2. Click OK.

      Progress bars will appear at the bottom of the spash screen as Eclipse loads.

      Eventually the Eclipse workbench will appear with a Welcome tab covering it.

    3. Terminate (click X on) the Welcome tab.

      You will not see the Welcome tab when you start Eclipse after this first time. You should now see the following Eclipse workbench.

      Notice the C/C++ words/icon appear on the top left (in the Window title-bar) and below the upper right-hand corner (beneath the tool-bar).

    4. To simplify the edit/build-recompile/run loop that we will discuss below, perform the following operation: after completing it, clicking Build or Run will automatically save the contents of any edited file before the program is rebuilt and run.
      • Select Eclipse | Preferences.
      • In the Preferences popup window disclose General and select Workspace.
      • Click "Save automatically before build" checkbox, as follows..

      • Click Apply.

      • In the Preferences popup window disclose Run/Debug and select Launching.
      • In the "Save required dirty editors before launching" section click the Always radio button as follows.

      • Click Apply.
      • Click OK.
      Once you have set up these preference in a workspace on your home machine, you will never have to peform this step again.

    Eclipse is now installed for C++. Start the Testing instructions directly below.


    Testing Eclipse, C++, and Libraries

    1. Download the ics46-templates.zip file and unzip it.

    2. Select File | Imports as shown below.

    3. Disclose General and select Existing Projects into Workspace as shown below.

    4. Click Next>
      Browse to the ics46-templates folder you downloaded and unzipped in above.
      Click the "Copy projects into workspace" checkbox, as shown below.

    5. Click Finish. The Project Explorer window should be updated to appear as follows.

      You can explore the courselib and googletestlib projects by disclosing/eliding their folders and subfolders. The software in these projects have already been built, so you do not need to build them here.

    6. Right-click the project icon in the Project Explorer tab and select Copy as shown below (or click project icon and use the Command+c shortcut for Copy) as shown below.

    7. Right-click the project icon in the Project Explorer tab and select Paste as shown below (or use the Command+v shortcut for Paste) as shown below.

    8. Rename it to be test_set as shown below

      and click OK.

    9. Disclose the test_set icon in the Project Explorer tab: it shows an src folder which should appear empty, as shown below

    10. Download and unzip test_set.zip.
      Copy/Paste all the files in its src folder into the src folder shown in the newly created and disclosed test_set project folder.
      Copy any data files (there is one: loadset.txt) into the newly created test_set project folder.
      Disclose the src folder, which should appear as shown below

    11. Double-click the driver.cpp file in the src folder.
      In the Editor tab for the driver.cpp file select all the lines (Command+a) and then uncomment them (Command+/).

      The Editor tab for the driver.cpp file should show the following.

      Notice the * prefixing the driver.cpp file name: this indicates the file has been modified but not saved. You can right-click in the file and select Save, but Eclipse will do that automatically when you build a project (if you correctly followed the instructions for installing it).

    12. Either click the test_set icon in the Project Explorer tab and then click the Hammer icon ; or right-click the test_set icon in the Project Explorer tab and select Build Project. The Console window should show the following.

    13. Either right-click the test_set icon in the Project Explorer or right-click in the driver.cpp Editor tab.
      Then select Run As and 1 Local C/C++ Application.

      The Console window should show the following.

      You can use this driver interactively to test various operations on the Set data type that is implemented by an array (from courselib). When you are done testing, the q command quits/terminates this code.

    14. Comment out all the code in the Editor tab for the driver.cpp file (Command+a followed by Command+/).
      Double-click the test_set.cpp file in the Project Explorer tab.
      Uncomment all the code in the Editor tab for the googletest.cpp file (Command+a followed by Command+/).
      Compile-Build and Run this code: because we are rerunning a project that has already been compiled-built and run, we can recompile-rebuild and rerun by just clicking the Run icon (). Knowing this shortcut is useful.

      Ignore the two warning message: this code uses a for-loop counter that is not used inside the loop. When prompted, type 1000 and enter, enter, and 1000 and enter (as shown in green below).

      The Console window should show the following.

      (note: this is actually a picture from my PC)

    Eclipse and C++ are now working correctly with the courselib and googletestlib


    For subsequent quizzes/programs, you can All these steps were shown above. You should never have to reimport the courselib or googletestlib, although I might instruct you to change some the the files in the courselib/src folder and rebuild the library: Read Updating the Course Library Instructions.