Eclipse setup (experimental)

Twan Koolen edited this page Jul 7, 2014 · 20 revisions

Drake-distro includes an Eclipse project file, making it easy to use the Eclipse IDE for Drake C/C++ development. This guide describes how to set up Drake in Eclipse and has been tested with Eclipse Luna. It is assumed that drake-distro is already installed. Eclipse support is currently experimental and only available on Linux and OSX.

Installing Eclipse

  1. Go to Download the version of 'Eclipse IDE for C/C++ Developers' that matches your operating system and architecture. Alternatively, if Eclipse is already installed, Install the C/C++ Development Tooling (CDT) (using Help > Install New Software...).
  2. There is no installer, so just extract the contents of the .zip file to the desired installation directory.
  3. Start Eclipse. Eclipse will prompt for a workspace location. Select or create any folder except the folder that contains your clone of drake-distro.
  4. Close the welcome tab. If you ever need it again, you can find it under Help > Welcome.
  5. If your operating system is OSX, install the C/C++ LLVM-Family Compiler Build Support plugin:
    1. Help > Install New Software...
    2. Work with the CDT update site that matches your version of Eclipse (found here)
    3. Expand CDT Optional Features and locate C/C++ LLVM-Family Compiler Build Support. If you can't find it, it may be hidden because it is already installed. Verify this by unchecking 'Hide items that are already installed'. Select, install, and restart Eclipse.

Importing the Eclipse project file

  1. Open the C/C++ perspective.
  2. Click File > Import...
  3. Select General > Existing Projects into Workspace and click Next.
  4. Select the directory where you cloned drake-distro. Leave all other settings to their defaults.
  5. Click Finish.

Setting up the tool chain

  1. Right click on the newly imported drake-distro project and click Properties.
  2. Navigate to C/C++ build. Click Manage Configurations... Select either drake-OSX or drake-linux, depending on your OS, and click Set Active.

Setting Eclipse preferences

  1. Click Help > Preferences... (Linux) or Eclipse > Preferences (OSX).
  2. Navigate to Run/Debug > String Substitution in the tree.
  3. Create the following string substitution variables (make sure there are no newlines or other whitespace characters in the paths):
    • GRB_LICENSE_FILE: set to the location of your Gurobi License file.
    • JAVA_HOME: set to JDK/JRE location.
    • MATLAB_ROOT: set to location of Matlab installation.
  4. Navigate to C/C++ > Indexer.
  5. Under 'Build configuration for the indexer', select 'Use active build configuration'.
  6. Click OK.

Importing formatter settings

  1. Right click on the drake-distro project and click Properties.
  2. Navigate to C/C++ General > Formatter.
  3. Click Import... Select eclipse/eclipse-formatter-settings.xml and click Open.
  4. Click OK.

Building Drake from Eclipse

Two make targets (clean and all are set up) in the Make Target view, which can be run by double clicking on them. Alternatively, use Project > Clean... and Project > Build all.

Debugging .mex functions

For each OS, two debug configurations are provided:

  • drake-distro debug ${OS}: starts the Matlab GUI, allowing you to run Matlab code.
  • drake-distro debug ${OS} nojvm: starts Matlab with the program argument -nojvm. In this mode, Matlab runs in the command line and starts faster. However, certain features that rely on Java may not be available.

To use the debug configurations:

  1. Click the drop down arrow next to the debug symbol and click the debug configuration of your choosing.
  2. If Eclipse asks you to confirm a perspective switch, click Remember my decision, then click Yes.
  3. Click the Resume button twice (or press F8 twice). The Matlab GUI should come up.
  4. In Eclipse, Set a break point anywhere in your C code by double clicking in the gutter.
  5. In Matlab, run code that calls the C code as usual. Execution should be halted when the breakpoint is hit, allowing you to inspect variables in Eclipse. Note that it appears that breakpoints only work after you've run the function at least once.