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

From Slicer Wiki
Jump to: navigation, search
m (Text replacement - "\[http:\/\/wiki\.slicer\.org\/slicerWiki\/index\.php\/([^ ]+) ([^]]+)]" to "$2")
 
(23 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
=Revised Howto Setup Eclipse to build/edit the Slicer3 Development Environment:=
 
=Revised Howto Setup Eclipse to build/edit the Slicer3 Development Environment:=
 +
 +
 +
<gallery>
 +
Image:Slicer-editing-in-eclipse.png‎|A Slicer editing session in Eclipse 3.5 (Gallileo).
 +
</gallery>
 +
  
 
==Installing Eclipse:==
 
==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 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.  
+
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 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:==
 
==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 [Slicer3:Eclipse | here].
+
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 [[Slicer3::Eclipse | here]].
  
 
==Modules for Eclipse you need:==
 
==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 [Slicer3::Eclipse | here] for instructions adding these packages into Eclipse.  The URLs for these two Eclipse plug-ins are:
+
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 [[Slicer3::Eclipse | here]] for instructions adding these packages into Eclipse.  The URLs for these two Eclipse plug-ins are:
  
 
# CDT – C++ Environment: [http://www.eclipse.org/cdt http://www.eclipse.org/cdt]
 
# CDT – C++ Environment: [http://www.eclipse.org/cdt http://www.eclipse.org/cdt]
 
# Subclipse: [http://subclipse.tigris.org/install.html http://subclipse.tigris.org/install.html]
 
# Subclipse: [http://subclipse.tigris.org/install.html 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". 
 +
 +
[[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 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.
  
  
==Creating Project and getting the Source-Code for it:==
 
  
 +
[[Image:Eclipse-build-ops.png|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 ' '''
  
* Right-Click on the project folder
+
== Continuing with Debugging under Eclipse==
* click on properties (or just press Alt+Enter)
+
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 [[Slicer3::Debugging_with_Eclipse_Instructions|http://wiki.slicer.org/slicerWiki/index.php/Slicer3::Debugging_with_Eclipse_Instructions]].
[[Image:Eclipse-Step5.png]]
 
* then at C/C++ Make Project
 
[[Image:Eclipse-Step6.png]]
 
* click on “Workspace...”
 
* select the unix folder from tcl or tk
 
[[Image:Eclipse-Step7.png]]
 
==Compile the projects:==
 
After successfully configuring all projects eclipse should start automatically building the application. If this is not the case, right click on project and select “Build Project” and see how the project is compiling.
 
=Download=
 
[[Media:Howto - Eclipse And Slicer3.pdf| How to Setup Eclipse – Slicer3 Development Environment]]
 

Latest revision as of 02:16, 27 November 2019

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.