Launch eclipse

  • Chaste developer machines: Choose "/home/chaste/eclipse/workspace" as the workspace location.
  • Comlab: It is advisable to set the workspace in your local space (eg /home/scratch/workspace/) rather than the networked home directory (eg /auto/users/<yourname>/workspace), since when compiled the workspace will get quite large and you would probably go over your disk quota if you chose the latter.

Install plugins

See InstallEclipsePlugins.

Set preferences

Recommended approach

For recent eclipse versions (Ganymede onwards) we ship a preferences file in the Chaste trunk. See source:trunk/eclipse_settings/README.txt for full instructions on using this, but in brief:

  • File -> Import... -> General -> Preferences and select file <path_to_chaste>/eclipse_settings/preferences.epf
  • Now check that it has implemented them properly - it usually doesn't due to some bug, here is a workaround.
    • Select 'Show Whitespace Characters` there should be a button for this in the toolbar.
    • Now bring up any Chaste .hpp or .cpp file put the cursor somewhere and press Tab. You will see either:
      • Four dots .... - Chaste settings have been applied - you are ready to go!
      • An arrow followed by spaces >> - settings aren't applied properly. In this case you then need to carry on with these instructions.
    • Go to Window->Preferences->C/C++->Code Style->Formatter.
      • You will see a box with Chaste as the Active profile, select a different active profile and press apply
      • Now re-select Chaste and click Apply then OK.
    • Repeat the tab test above, and you should now see four dots ...., and Chaste settings have been applied correctly.

For older eclipses

If the above is not possible, since the menu's aren't there, certain key preferences may be set manually.

  • You are advised to use visible tabs (so you can double-check tab settings). Go to Window->Preferences->General->Editors->Text editors->Show whitespace->Configure visibility, then select checkbox for visible tabs (and trailing spaces).
  • Use "Insert spaces for tabs" -- Please make sure you do this
    • Newer versions of eclipse (from around version 3.5.2): go to Window->Preferences->General->Editors->Text Editors, and select "Insert spaces for tabs".
      • You may have to turn if off and on again. Window->Preferences->C++->Code Style->Formatter->Edit->Tab Policy switch from "spaces only" to "tabs only" and back again to "spaces only".
    • Older versions of eclipse: go to Window->Preferences->C/C++->Editor->Appearance and select "Insert spaces for tabs".
  • Unclick Project -> Build Automatically

To set indentation and whitespace preferences:

  • Window -> Preferences -> General -> Editors -> Text editors -> Show whitespace (for visible tabs)
  • Window -> Preferences -> C++ -> Code style -> Formatter -> Edit -> Indentation
    • If you find that the eclipse preferences file imports the Chaste code style with spaces for tabs, but tabs are still appearing, then this can be fixed by switching from "spaces only" to "tabs only" and back again in the formatter indentation settings.

(Optional) See MakeEclipseBuildTheTestThatIsOpen to set up eclipse to allow you to run the currently open test

Unresolved include errors (red underlining)

Sometime Eclipse pretends it has never heard of things like std::vector and so it underlines in red everything that uses them - so nearly all Chaste classes. This makes your scroll bar all red, prevents using F3 to get to definitions, and is generally very annoying. The solution is to:

  1. Right click your project ("Chaste" by default) and select Properties
  2. Navigate to "C/C++ General" -> "Code Analysis" -> "Preprocessor Include Paths, Macros, etc."
    • If you see "This project is not a CDT project" then you first need to select the Chaste project and do File->New->Convert to a C/C++ Project (as the CDT settings need updating for newer Eclipses), then carry on with these instructions...
  3. Choose the "Providers" tab
  4. Enable "CDT GCC Built-in Compiler Settings"

It will refresh the whole project which takes a while but now everything is highlighted properly.

In a similar way it's possible to tell the indexer to look for other includes such as PETSc:

  1. Enable "CDT User Setting Entries" in the previous window
  2. Go back to the "Entries" tab
  3. Select "GNU C++". Built in and User Settings should be there.
  4. Select User Setting Entries and click Add.
  5. Enter Include Directories (like PETSc/include) and select "system headers", and define macros (like CHASTE_CVODE=1) to your heart's content.

Create a script to remove subversion id on starting Eclipse (optional)

If you are on a machine that lots of people are going to use for development work, you will want to remove any saved svn login details easily. If you aren't you can ignore this section.

Create a file called ~/bin/eclipse containing the following:

. ~/.bashrc

/bin/rm -f ~/.subversion/auth/svn.simple/*
/bin/rm -f ~/.eclipse/org.eclipse.platform*/configuration/org.eclipse.core.runtime/.keyring

# Make JavaHL work!
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/lib/svn-javahl


(You can create such a file with the command: gedit ~/bin/eclipse )

Make that script executable:

chmod +x ~/bin/eclipse

Add an Eclipse Icon (optional)

Right click on the desktop and choose Create Launcher. Enter the following:

  • Name=eclipse
  • Command=/home/chaste/bin/eclipse

Fedora: You can select the eclipse icon by clicking on the "no icon" button. Ubuntu: The default icon is too small (32 pixels wide). Select the icon in the properties dialog and edit it to /usr/share/pixmaps/eclipse48.png

Note for users of Chaste releases

The above instructions are aimed primarily at core Chaste developers; your setup may involve different paths, etc. The WorkshopSessionD2 wiki page gives instructions for using Eclipse with a copy of the Chaste release source code.

Last modified 7 years ago Last modified on Jul 15, 2015, 12:31:18 PM