SE 2040 Eclipse Notes

Installing Eclipse with C++ Support

These directions are based on Eclipse CDT Mars.

  1. Open a command prompt (Start | All programs | Accessories | Command Prompt). You will probably want to right click on it in the accessories folder and select "Pin to start" to make it easier to access.
  2. Type
            java -version
    
    and confirm you have version 1.7 or later installed.
  3. We will use Chocolatey to install C++. Right click on your command prompt icon in your start menu and select "Run as administrator". Visit chocolatey.org and follow the steps under "Easy Install" to execute the @powershell command that will download and install the tool.
  4. Execute the command
            choco install mingw
    
    in the administrative command prompt. "MinGW" is "Minimalistic GNU for Windows".
  5. After it is installed, open a new command prompt (it does not have to be an administrator prompt) and type
            gcc --version
    
    If you get an error about the command not being found, open the System dialog (it can generally be found by right clicking on the windows start icon), selecting Advanced, Environment Variables, and editing the PATH variable to add the folder containing gcc.exe. In many cases this folder will be c:\tools\mingw64\bin. Close the dialog, open a new command prompt (so the new setting for PATH becomes effective), and confirm gcc (and g++) are installed.
  6. Visit the folder containing gcc. If you are not sure where it is, you can type where gcc to find it. Make a copy of gcc.exe and name it mingw32-gcc.exe. The location of this file is used by Eclipse to find the MinGW libraries.
  7. Other packages you could consider installing:
            choco install -y notepadplusplus        # Notepad++
            choco install -y vim-x6                 # edit using vi
            choco install -y git                    # works, but does not provide
                                                    #   the explorer context menus
            choco install -y gow                    # many unix utilities
            choco install -y sqlite sqlite.shell    # SQLite support
    
  8. Reboot your computer to so that the new setting of PATH is available to all applications.
  9. Download Eclipse IDE for C/C++ Developers from here. Make sure you get the one for C/C++ developers - the Java one will not work for SE 2040.
  10. Unpack the .zip to a folder; I use c:\apps to avoid cluttering up C:\.
  11. Open Windows Explorer and browse to the Eclipse executable. Right click on it and select "pin to start menu"
  12. Start Eclipse.
    1. It will prompt you for a workspace. This is where temporary build files will be placed and is the default location for project sources. You can simply use the same workspace for all projects and save source files inside a separate repository.
    2. Click on the workbench icon in the upper right.
    3. Turn off hard tabs by visiting Window|Preferences, and selecting
      • General | Editors | Text Editors | check Insert spaces for tabs
      • C/C++ | Code Style | Formatter; click the New button to create a new profile, then OK to continue. The system will pop up a formatting dialog; on the Indentation tab, change the policy to "Spaces only"
      Both are needed: the first only affects regular text files. Note that you may need to similar steps to avoid tabs with Java files.
    4. Making C++11 the default for the editor:
      1. Windows|Preferences
      2. Expand C/C++ and Build and then click on Settings
      3. Select the Discovery tab
      4. Click on CDT Cross GCC Built-in Compiler Settings
      5. in the "Command to get compiler specs" box add
                -std=c++11
        
      You may need to restart Eclipse to apply the setting to current projects. But while you're in the neighborhood, you might also set GCC to be the default compiler for new projects by clicking on New C/C++ Project Wizard, then on MinGW GCC, and finally on the Make toolchain(s) preferred button.
    5. Open File | New | C++ Project, select Hello World C++ Project, MinGW GCC, and set the project name.
      • If you plan to use your own repository manager such as git, deselect "Use default location" and browse to where you want your project to live within your repository.
    6. Select Project | Build All
    7. Click on the Green run arrow, your output should show in the console at the bottom of the screen.
If you use any C++11 features in a project, do
  1. Project | Properties
  2. Expand C/C++ Build and click on Settings
  3. Under GCC C++ Compiler click on Dialect
  4. Set the Language standard to ISO C++11
  5. Click OK

More Information