Slicer3::New Eclipse Instructions

From Slicer Wiki
Revision as of 02:16, 27 November 2019 by Grundlett (talk | contribs) (Text replacement - "\[http:\/\/wiki\.slicer\.org\/slicerWiki\/index\.php\/([^ ]+) ([^]]+)]" to "$2")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Home < Slicer3::New Eclipse Instructions

Revised Howto Setup Eclipse to build/edit the Slicer3 Development Environment:


Installing Eclipse:

These instructions have been tested with Eclipse editions including "Ganymede" (3.4), "Galileo" (3.5), and "Helios" (3.6), but this should work with any Eclipse Version 3.3 or higher. The easiest way to get started is to select an eclipse distribution which already includes CDT, the C++ development tools, integrated. This is available from http://www.eclipse.org/downloads. Download Eclipse and unpack the downloaded archive to the destination you want. You start Eclipse by executing ./eclipse from the base directory of your eclipse installation.

Configure Eclipse:

As computers become more powerful, it is less necessary to adjust the runtime parameters of Eclipse, but some tweaking hints are listed on the original Eclipse page here.

Modules for Eclipse you need:

As mentioned above, it is easiest to start with an integrated Eclipse containing CDT already. However these prebuilt configurations were available only in 32-bit versions the time of this writing. So some users who need full 64-bit versions may need to configure Eclipse by hand. If this is the case, the CDT tools can be integrated by hand into Eclipse. If you want to use Eclipse to connect to Slicer's SVN repository and compare versions, update source, etc. (highly recommended), then you'll need to add the Subclipse package to Eclipse. Please see the original Eclipse Wiki page here for instructions adding these packages into Eclipse. The URLs for these two Eclipse plug-ins are:

  1. CDT – C++ Environment: http://www.eclipse.org/cdt
  2. Subclipse: http://subclipse.tigris.org/install.html

Creating an Eclipse Project for Slicer3:

Step 1: Build Slicer3 outside of Eclipse using getbuildtest.tcl or your alternate build system of choice.

For this discussion, lets assume "/Users/dot/Projects/slicers/trunk-012210" contains the Slicer3* directories. So we could go into /Users/dot/Projects/slicers/trunk-012210/Slicer3-build and type "make".

Step2: Create a new C++ project in Eclipse. Yes, it is a Makefile project. Uncheck "Use default location". Select the Browse function and navigator to the Slicer3 source directory for the Eclipse project location. In our example case, we would select "/Users/dot/Projects/slicers/trunk-012210/Slicer3". In my version of Eclipse (Galileo), it now has more options for the Project. I selected "Makefile Project" and specified "Empty Project".

Create Project

Step 3: Click "Finish" to create the project. We will edit the project info later to get it really working. The C++ indexer may take a few minutes the first time it is consuming the whole Slicer tree during this step. After this, it is pretty fast.

Step 4: You should see the project in the Explorer tab on the left now. Select then right click the project we just created. Mine was called "Slicer-trunk" and edit the project properties (the entry at the very bottom of the pop-up menu). The project properties dialog should pop up.

Step 5: Select the "C/C++ Build" branch of the tree diagram on the left of the dialog. In "Builder Settings", uncheck "Use default build command" .

Step 6: Enter the make command we want to use. Notice that we specified four jobs (to build faster) and specified the location to use as the current directory for the build:

make -j 4 -C Users/dot/Projects/slicers/trunk-012210/Slicer3-build

Step 7: In the same pop-up window, enter the build directory again in the "Build location" dialog (same pathname as you just entered above in step 6). Now you can click OK to accept these entries. Eclipse should start building the project right away. You can see the C++ compilations go by in the "Console" tab at the bottom. We are using Eclipse to fire off the makefile built by cmake. This means we can still go outside Eclipse and type "make" by hand anytime. Eclipse just knows how to fire off the make when necessary.


Eclipse Build Options Dialog


At this point, Eclipse will be able to compile Slicer3 but not able to run Slicer3 from the execute project icon, yet.

Step 8: Quit Eclipse and setup a shell which has the Slicer3 environment defined in the shell before running Eclipse inside the shell. In Linux or Mac, this can be done using a Bash shell script found in the Slicer3 build directory (/Users/dot/Projects/slicers/trunk-012210/Slicer3-build/bin/Slicer3Setup.sh in our example). A shortcut can be created, using a shell alias, similar to the following example. I define this in my list of aliases auto created during login:

alias trunk='source /Users/dot/Projects/slicers/trunk-012210/Slicer3-build/bin/Slicer3SetupPaths.sh; ~/Desktop/eclipse/eclipse '

Continuing with Debugging under Eclipse

At this point, you should be able to build Slicer using Eclipse and run Slicer from inside Eclipse. If you want to debug Slicer interactively under Eclipse, there is a bit more configuration to perform. Please continue with the debugging instructions found at http://wiki.slicer.org/slicerWiki/index.php/Slicer3::Debugging_with_Eclipse_Instructions.