Eclipse C++ Mac

This document describes how to install everything necessary to develop with C or C using only free tools on the three major operating systems Windows, Linux, and Mac OS X. It uses the Eclipse IDE, which is the same on all operating systems, thus providing a consistent user experience once installed. NOTE: If you are on a Mac and when you run your tests, and it complains about character encoding, this may be due to a quirk in how Eclipse launches from the Finder. Launch it once from the command line, and it should fix itself from there. For the beginning C student who is familiar with the Mac, this is a great way to go. But there are more options, so off we go. Next: Method #2 – Install Linux as a Virtual Machine in macOS.

  1. Eclipse Mac C++ Debugger

Install a new version of Eclipse to use with C++

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

Eclipse: Version 4.5 (Mars)

The Eclipse download requires about 200 MB of disk space; keep it on your machine, in case you need to re-install Eclipse. When installed, Eclipse requires an additional 200 MB of disk space.

Downloading

  1. Click Eclipse

    The top of the following page will appear in your browser.

    In this handout we will download Eclipse Standard 4.5 for Mac OS X 64 Bit; if your computer uses Mac OS X (Cocoa), continue below; otherwise look for the pull-down list showing Mac OS X (Cocoa) and instead choose either Windows or Linux and then continue below.

  2. Click the 64 Bit (under Mac OS X) under the heading Eclipse IDE for C/C++ Developers (the fourth selection from the top).

    You will see the following page (don't worry about the name of the institution underneath the orange DOWNLOAD button).

  3. Click the orange DOWNLOAD button. The site named here, in orange, underneath the DOWNLOAD button: United States - Indiana Unversity (http) is the random one chosen by the download page this time; yours may differ.

    This file should start downloading in your standard download folder. This file is about 200 Mb so it might take a while to download fully if you are on a slow internet connection (it took me about 5 minutes over a cable modem). Don't worry about the exact time as long as the download continues to make steady progress. In Chrome progress is shown on the bottom-left of the window, via the icon

    The file should appear as

    Terminate the window browsing the Eclipse download.

  4. Move this file to a more permanent location, so that you can install Eclipse (and reinstall it later, if necessary).
  5. Start the Installing instructions directly below.

Installing

  1. Double click the file eclipse-cpp-mars-R-macosx-cocoa-x86_64.tar.gz, the file that you just downloaded and moved. It will unzip the file and create an Eclipse application, which appears as

    Move this application into the Applications folder and put it on the dock for simple access. Now you are ready to perform a one-time only setup of Eclipse on your machine.

  2. Double-click the Eclipse icon on the Dock that you just created above.

    The following pop-up window will appear

    (note it says Eclipse Cpp here, because I already have Eclipse installed for my work with Python, so on my machine I renamed this application Eclipse Cpp.

  3. Click Open.

    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 /Documentsworkspace, 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.

  4. 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.

  5. 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).

Eclipse is now installed for C++.

Xcode

In this section we will download/install Xcode. Before downloading XcodeEclipse c++ mac os x (this software is free) you must have an itunes account.
  1. Download/Install Xcode by opening a browser and pasting the following url: https://developer.apple.com/xcode/downloads/.

    It will pop-up the following Developer window.

  2. Click the View in Mac App Store > link. It will bring pop-up the following itunes window
  3. Click the Get button (underneath the hammer). The pop-up window will change to
  4. Click the Install App button (same location).
    When I did this, I received the following message in a pop-up window (because I am running Mac OS 10.9.5).

    At this point I clicked OK and returned to the original Xcode window, scrolled to the bottom (left), and clicked on the Additional Tools link. I was redirected to login with my Apple ID.

    I entered my Apple ID and password and clicked Sign In.
    Next a pop-up window with an Apple Developer Agreement appeared; I scrolled to the bottom.

    I clicked the box binding me to the agreement and clicked the Submit button.
    Next a pop-up window with various developer tools appeared. Mac reboot into recovery mode. I scrolled down to Xcode 5.1 (dated April 9, 2014) and clicked on the + to disclose the Xcode 5.1.1.dmg link.

    I clicked this link; note the download occupies 2.1Gb of storage: my download took 30 minutes. Then I double clicked the downloaded .dmg file and a pop-window showed itself briefly.

    Then a pop-window window asked me to drag/drop Xcode to the Applications folder.

    I dragged/dropped Xcode to the Applications folder, and a pop-up window showed itself during the copying.

    Then I repeated these steps for Xcode's command line developer tools. I scrolled to Command Line Tools (OS X 10.9) for Xcode - September 2014 (dated September 1, 2014) and clicked on the + to disclose the link.

    I clicked this link; note the download occupies 102Mb of storage: my download took just a few minutes. Then I double clicked the downloaded .dmg file and a pop-window showed itself briefly, followed by the following pop-up window.

    I double clicked the icon and the following pop-up window appeared, with the word Introduction highlighed.

    I clicked the Continue button, and following pop-up window appeared, with the word License highlighed.

    I clicked the Continue button, and following pop-up window appeared

    I clicked the Agreee button, and following pop-up window appeared, with the word Installation Type highlighed (it skipped highlighing the Destination Select.

    (this image appears to be missing)
    I clicked the Install button, and following pop-up window appeared.

    I entered my password and clicked the Install Software button, and following pop-up window appeared, showing the installation progress.

    Eventually, that window was replaced with the following pop-up window with the word Summary highlighed.

    I clicked the Close button and terminate the Command Line Developer Tools window.

  5. Open a terminal and type (don't copy/paste) to its prompt: xcode-select --install as shown below.

    I pressed return and following pop-up window appeared

    I clicked the Install button, and following pop-up window appeared.

    I clicked the Agreee button, and following pop-up window appeared briefly.

    When it disappers, the following pop-up window appeared.

    I clicked the Done button. Then I closed the terminal window.

  6. Go the the Launchpad and double click the Xcode icon. The following pop-up window will appear briefly

    It is replaced by the following pop-up window.

  7. Click Open. The following pop-up window will appear

    Click Agree. The following pop-up window appeared.

    I entered my password and clicked OK. The following pop-up window will appear briefly

    It is replaced by the following pop-up window.

    Click Open Other and the following pop-up window will appear (yours might have diffierent documents, but it should show the workspace that you created when you started Eclipse). Click that workspace (to select it) and click Open.

    KLUDGE: is this necessary? Could I have dismissed this window and still have run the code?

The require Xcode software is now installed.

Eclipse Verification

In this section we will Eclipse/C++ is working correctly.
  1. Re-open Eclipse if it is not open.
  2. Start a new project by clicking on the 'down-pointing' black triangle to the right of the left-most icon on the Eclipse tool-bar (not at the top of the screen, but on the window runnin Eclipse). Fill in the Project Name as test; in Project type ensure Empty Porject is selected; in Toolchains ensure MacOSX GCC is selection. The pop-up window should appear as

    Click Finish.

  3. Right click the test folder and select Source File as shown in the window below.
  4. Enter trivial.cpp after Source file: as shown in the window below.

    Click the Finish button.

  5. Copy/paste the following text starting at line 8 in the trivial.cpp editor.
  6. Right click in the *trivial.cpp editor tab and select Save.

    The * in the editor tab (meaning the file is unsaved) should disappear.

  7. Click the hammer (or right-click the test folder and select Build Project) and the Console window at the bottom (click it if it is not active) should show a successful build.
  8. Right click in the trivial.cpp editor and select Run as and then 1 Local C/C++ Application. The Console window should show a successful run. You can run this application in the future by clicking the right-pointing white triange in the green circle (the leftmost one of the three).

You have now verified the installation of Eclipse for C++.

Step 0: Installing Java

Before you start installing Eclipse, make sure that you have the Java Development Kit (the JDK) installed on your system. If you're not sure, it's safe to just try installing it again. (If you already have the JDK installed, installing it again will just update you to a slightly newer version.)

To download the JDK, go to this page and download the appropriate file for your operating system.

Note: while the latest version of Java is Java 9, we strongly recommend you use Java 8 in this class. While our course projects in theory work with Java 9, they have only been tested with Java 8. The link above will take you to the Java 8 download page.

Step 1: Installing and configuring Eclipse

Step 1a: Download

NOTE: if you used Eclipse before, you may have an older version installed. If so, we strongly recommend you uninstall it and install the latest version for maximum compatibility.

You can download Eclipse at eclipse.org/downloads. The latest version, as of time of writing, is Eclipse SimRel.

Step 1b: Installation

  1. Run the Eclipse installer. You should see a window like the one below; Select the first 'Eclipse IDE for Java Developers' option.

  2. After that point, you can keep hitting 'yes' and select all the default options (unless you want to change something).

    You should eventually see a screen like this. Click the 'Launch' button.

    Note that there are some third party libraries that we use, such as JUnit, that are included in the projects and managed with Gradle; see the project import guide for more details.

Eclipse C++ Mac

Step 1c: Configuration

  1. When you run Eclipse, it'll ask you where you want your workspace to be (see screenshot below for example). Your workspace will be the location where Eclipse will add any new projects you create. You can change the location of the workspace if you want: just make sure you remember what you picked.

  2. Once you're done, you should see a 'Welcome' screen like below. Close the 'welcome' tab to open the regular editor.

  3. Next, select 'Windows > Preferences' (PC) or 'Eclipse > Preferences' (Mac) in the menu. Then, select 'Java > Installed JREs':

  4. Click the 'Search' button and select the 'Java' folder. This folder should contain your installed JRE and JDK. (If it contains only the installed JDK, that's also ok). You can probably find this folder located at:

    • Windows: C:Program FilesJava
    • Mac: /Library/Java

    For example, on Windows:

  5. After hitting 'ok', you should see a screen with a line for either both the JRE and the JDK, or just the JDK. Select the line for the JDK:

  6. Click the 'Apply and close' button.

  7. Eclipse, by default, contains a fair degree of clutter. If you want to minimize the clutter, feel free to close the 'Task List' and 'Outline' tabs/views to the right.

Step 2: Configuring checkstyle

We will start by installing a plugin named 'checkstyle', which when run will check your code for different style issues.

Step 2a: Installing the plugin

  1. In the menu bar, click 'Help' > 'Eclipse Marketplace'

  2. Search for 'checkstyle' (the search bar is near the upper-left). You should now see something like this:

  3. Select the option labeled 'Checkstyle Plug-in 8.x.x'. (The exact version number may be different from our screenshot). Click the 'Install' button in the lower-right of that option. You should ignore any other plugins that show up.

    At some point, Eclipse will ask you to accept some license agreements. Accept them, and move on.

  4. Once you are done, Eclipse will tell you that it needs to restart to make sure all changes take effect. Click the 'Restart Now' button.

Step 2b: Loading the CSE 373 style rules

  1. Once Eclipse has finished restarting, we need to load our CSE 373 specific rules.

    Start by downloading and saving our checkstyle rules by clicking 'File' > 'Save as'. Make sure you remember where you saved the file! You probably want to save these rules someplace on your computer that's stable to make sure you don't delete it by accident later.

    (Note: if you previously had the checkstyle plugin installed before starting this class, you will most likely need to update it so that it can understand our rules file.)

  2. In the menu bar, click 'Window' > 'Preferences' (PC) or 'Eclipse > Preferences' (Mac). Navigate to the 'Checkstyle' option. You should see a window that looks like this:

  3. Click the 'New..' button. In the window that appears..

    • Set the 'Type' to 'External Configuration File'.
    • Set the 'Name' to 'CSE 373 Style' (or any other name you want).
    • Set the 'Location' to wherever the XML file you just downloaded is located.
    • Check the 'Protect Checkstyle configuration file' option at the bottom.

    Your screen should look like this:

  4. After clicking 'OK', you should now be back to the 'Preferences' window. Select the configuration we just uploaded, and click the 'Set as Default' button. Your screen should now look like this:

  5. Click 'Apply and Close'.

Step 3: Adjust Eclipse defaults

Eclipse c++ mac binary not found

Step 3a: Enable stricter generics checks

The next step is to configure Eclipse so it catches a common generics-related issue:

  1. In the menu bar, click 'Windows' > 'Preferences' (PC) or 'Eclipse > Preferences' (Mac)

  2. Within the left sidebar, expand 'Java' > 'Compiler' > 'Errors/Warnings'.

  3. Within that window, expand the 'Generic types' section and change the 'Usage of a raw type' option from 'Warning' to 'Error'. After making these changes, your screen should look like this:

  4. Click 'Apply'.

Step 3b: Indent using spaces

A common point of contention among programmers is whether we should indent code using the t character, or by using some number of spaces instead. Personally, we don't really care, but the code we've provided you consistently uses 4 spaces per indent.

Unfortunately, Eclipse defaults to using the t character instead. This is annoying because it causes the indentation in your codebase to be inconsistent. The next step is to modify Eclipse so it matches our class standard.

  1. At this stage, you should still have the window from step 3a open. If you closed it by accident, reopen it by clicking 'Windows' > 'Preferences' (PC) or 'Eclipse > Preferences' (Mac) from the menubar.

  2. Within the left sidebar, expand 'Java' > 'Code Style' > 'Formatter'. You should see a window like this:

  3. Click the 'Edit' button, in the upper-right corner of the screen.

  4. In the window that appears, edit the Profile name in the top of the screen to 'CSE 373 Styles' (or something similar).

  5. Next, in the 'Filter' input area type 'tab'. You should see the 'Tab Policy' option. Change it to 'Spaces only.' Your screen should look like the following:

  6. Click 'Ok'.

  7. Click 'Apply and Close'.

Step 4: Adding SSH key to access Gitlab

Step 4a: Add SSH key to Eclipse

Eclipse C++ Mac
  1. In the menu bar, click 'Windows' > 'Preferences' (PC) or 'Eclipse > Preferences' (Mac)

  2. Within the left sidebar, expand 'General' > 'Network Connections' > 'SSH2' and click he second section named 'Key Management' in the menu bar. You should see a window that looks like this:

  3. Click the 'Load Existing Key..' button and see if there is a file named 'id_rsa' listed. If there is, select the file and click 'Open'. If not, click 'Cancel' and click the 'Generate RSA Key..' button.

  4. If you want to add a password for better security, do so in 'Passphrase:' and 'Confirm passphrase:' boxes.

  5. If you clicked 'Generated RSA Key.' 2 steps ago, click 'Save Private Key..'. Otherwise skip to the next step.

  6. Click 'Apply'.

Step 4b: Adding your SSH key to Gitlab

If you did not generate a new SSH key and you have already entered this SSH key into Gitlab, you may skip this step.

Eclipse C++ Mac

Eclipse Mac C++ Debugger

  1. Copy your ssh key from the large white box in the 'Preferences' window.

  2. Go to Gitlab at https://gitlab.cs.washington.edu and sign in with your CSENetID if you have one, or UWNetID if you don't. You all should have access to Gitlab, but if you don't for some reason, email the course staff ASAP.

  3. In the upper right hand corner, click the silhouette and click 'Settings'. On the 'User Settings' page, click the 'SSH Keys' tab, which appears on the left hand menu bar.

  4. In the 'Key' text box, paste the SSH key that you copied from Eclipse.

  5. Create a nickname your this key, '373_Eclipse' is a good option, and click the 'Add Key' button.

  6. You can now log out of Gitlab and return to Eclipse.

  7. In the open 'Preferences' window, click 'Apply and Close'.