Difference between revisions of "Slicer3::New Eclipse Instructions"

From Slicer Wiki
Jump to: navigation, search
Line 26: Line 26:
  
 
'''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 "/usr/local/slicers/trunk/Slicer3".  In my version of Eclipse (Galileo), it now has more options for the Project.  I selected "Makefile Project" and specified "Empty Project".   
 
'''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 "/usr/local/slicers/trunk/Slicer3".  In my version of Eclipse (Galileo), it now has more options for the Project.  I selected "Makefile Project" and specified "Empty Project".   
 +
 +
[[Image::Eclipse-create-project.png|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 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.  

Revision as of 21:39, 18 February 2010

Home < Slicer3::New Eclipse Instructions

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


Installing Eclipse:

I currently use Eclipse "Ganymede" (3.4) and "Galileo" (3.5) versions, but this also works with Eclipse Version 3.3 and higher. The easiest way to get started is to select an eclipse distribution which already includes CDT (the C++ 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 with ./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 "/usr/local/slicers/trunk" contains the Slicer3* directories. So we could go into /usr/local/slicers/trunk/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 "/usr/local/slicers/trunk/Slicer3". In my version of Eclipse (Galileo), it now has more options for the Project. I selected "Makefile Project" and specified "Empty Project".

[[Image::Eclipse-create-project.png|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 /usr/local/slicers/trunk/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.

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 (/usr/local/slicers/trunk/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 /usr/local/slicers/trunk/Slicer3-build/bin/Slicer3SetupPaths.sh; ~/Desktop/eclipse/eclipse '