How to set up Eclipse for ROOT

This tutorial aims to introduce Eclipse as and IDE for code development involving ROOT. If you already familiar with the usage of Eclipse for ROOT you can skip to the next section.


ROOT can be downloaded from You can either download a binary for your system or compile it from source. A 'How to' is given on the ROOT homepage.

However, if you want to debug ROOT applications down to ROOT objects, you need a debug version of ROOT. This can be obtained by compiling ROOT with a debug flag.

Recommended location

While you can install ROOT in any folder you wish it is recommended to install it to a location which does not require admin right. Since you will at some point end up with multiple ROOT versions (switching from one to another) I recommend this setup:
#create /software/root if not existent
sudo mkdir -p /software/root
#change the owner
sudo chown -R <yourusername> /software
#you no longer need admin rights to install something here
cd /software/root
#get the latest ROOT version
#untar it, tar -zxf file
mkdir v5.XX.XX
mv root v5.XX.XX/normal
cp -r v5.XX.XX/debug
#now you are set up to compile ROOT for both normal use and debugging

Compilation of ROOT

Normal version:

cd myROOT_version
./configure --enable-roofit --enable-minuit2 --enable-builtin-freetype
make -j2

Debug version:

cd myROOT_version
./configure --build=debug --enable-roofit --enable-minuit2 --enable-builtin-freetype
make -j2

Special instructions for Mac user

  1. Make sure you have the latest XCode version installed (comes with all the libraries and includes you will need)
  2. configure ROOT with the appropriate python include and library paths
    #find out the location of your python installation:
    which python
    #copy & paste the lib and include locations into the command below
    ./configure --enable-roofit --enable-minuit2 --enable-builtin-freetype 
    make -j2

Get rootplot

This is optional for version <= 1.0.

Install rootplot (once PyROOT is configured)


Get rootpy

sudo easy_install rootpy
Or follow manual instruction on

Get Eclipse

Eclipse is a free IDE for various programming languages. Interesting for this tutorial are Eclipse's capabilities in C++ and Python.

Eclipse can be obtained from the Eclipse website: Get Eclipse

In the download section, choose the right version for your operating system. Note that for Linux OS you have the possibility to download Eclipse with additional Linux tools (recommended).



In case you are using a 64bit Linux, you will need to add following line to 'eclipse.ini' (workaround for bug in Java):


First steps

At the first start you will be prompted for the workspace, the area/folder/path you will create your projects in. Once started, you should find something like this:


Click on the arrow highlighted in red. This will get you to the project explorer.

Create a new C++ project (with ROOT)

First let's test if C++ is set up correctly. In order to create a new C++ project, right-click on an empty space in the project explorer and select 'New->C++ Project':


This will get you to the project wizard. For now we only want to create an simple 'Hello World' project:


Select it, name the project 'HelloROOT' and press finish.

All is left is to run our application now: click the green arrow button ('play').


'!!!Hello World!!!' should be now displayed in the console below the code.

Set environment variables

In order to compile our own ROOT application we need to tell Eclipse where ROOT is installed.

This is done by setting environmental variables under:



You will need to set ROOTSYS and LD_OLIBRARY_PATH to your ROOT install and library directory.

Edit Indexer

Once inside the preferences of Eclipse we can also edit the Indexer options. The Indexer will index the source code and prepare it for code-assist (auto-completion, code preview, etc.).

Two settings need to be changed:

  • select the checkbox for 'index unused headers
  • Select 'Use active build configuration' under 'Build configuration for the indexer'
  • (optional) increase the absolute memory limit of the indexer (useful for big projects)


Set include and library path

Once the environment variables are set we can include ROOT in our project. In order to do so, right-click on the project and select 'preferences'.


Now go to 'C/C++ General-> Paths and Symbols' and choose the 'includes' tab and the 'GNU C++' entry.

Add a new variable:


Next the same with the library path:


Edit linker settings

Once the paths are set you will need to edit the linker settings. You can find them under project preferences-> C/C++ Build -> Settings.

Note: If you are using OS X make sure to switch you linker under C/C++ Build -> Tool chain editor to MacOSX GCC tool chain (instead of Linux GCC tool chain).


Under Linker -> Miscellaneous you have to add following option:

-L/usr/local/lib `${ROOTSYS}/bin/root-config --libs --glibs --cflags --ldflags --auxlibs --auxcflags` -pthread -lm -ldl

If you are a linux user you will also have to move ${FLAGS} to the end in the GCC C++ Linker path

Edit Run settings

The only thing left to do is to ensure Eclipse finds the linked ROOT libraries at runtime. For this we enter the Run Configurations:


Select 'HelloROOT' configuration (which was created before the first run) and go to the tab 'Environment':


Enter the path to $ROOTSYS/lib.

To test the setup modify the source code of HelloROOT.cpp:

#include <iostream>
#include "TH1F.h"
#include "TCanvas.h"

using namespace std;

int main() {
	cout << "!!!Hello ROOT!!!" << endl; // prints !!!Hello World!!!
	TCanvas *c1 = new TCanvas("c1","test", 600,600);

	TH1F *hist = new TH1F("test", "test", 100,0,1);


	delete c1;
	return 0;

Now run the project. If successful it should create a image file, test.png, in the project directory.

Set up PyROOT

Install PyDev

Since Python is widely used within the collaboration, it is useful to teach Eclipse how to interpret it. Luckily most of the work is already done for you and all is left is to install an Eclipse plug-in: InstallNewPlugins.png

Then add the PyDev project site:


And finally select PyDev for installation:


All is left is to follow the steps of the installation wizard. At the end of the installation a restart of Eclipse is required.

Set the Python interpreter

Next we have to tell Eclipse which Python interpreter we want to use. Usually (on Linux) you want to use the default interpreter on your system, /usr/bin/python:


Confirming our selection you will be prompted for additional paths you want to include to your PYTHONPATH. If you've followed the steps until now you will be given the option to add your $ROOTSYS/lib path:


Create PyDev project for PyROOT

Now we can create our own PyROOT project (the same way as the C++ project):


In the src folder we create a new Python module, with following content:

from ROOT import TCanvas, TH1F

if __name__ == '__main__':
	print "!!!Hello ROOT!!!"
	c1 = TCanvas("c1","test", 600,600);

	hist = TH1F("test", "test", 100,0,1);


	del c1;

Once saved you can run it as 'Python Run'. That's it, ready to start the real work.

NOTES: By design the ROOT import resolves dynamically, which means at runtime, which has at least two consequences:

  • ROOT import as not correctly recognised in the editor, but it run fine.
  • auto-completion is not available for PyROOT

How to set up Eclipse for the BristolAnalysisTools

boost libraries

The Bristol AnalysisTools use smart pointers to great extend. Smart pointers are part of the new C++0x Standard, which is still in development. The implemented features are available in the form of the boost libraries. The libraries can be downloaded here: It is recommended to place the libraries in '/usr/include/' as this is the value already set in the project configuration. However, this can be changed at any time.

With ROOT, PyDev and boost libraries set up the analysis code can now be checked out from the CVS/SVN repository.

Import project from CVS/SVN

In order to import a project from a repository right-click on an empty space in the project explorer and click on 'Import ...'.



For CVS select 'Projects from CVS'.


You will need to enter the location of the repository. Use

Repository Path /cvs_server/repositories/CMSSW
user your cern user ID
password you cern password

Under 'connection type' select extssh. If you want you can save your password.


In the next step you can specify the name of the project. Follow the import wizard to the end.


The repository contains Eclipse configuration files and the project will start building when imported. However, the standard recipe includes tcmalloc, a library for performance analysis. You will have to either remove it in the linker step (linker under libraries) or download the Google Performance tools (described here)

You are now ready for analysis.


If you haven't installed SVN already, goto to Install SVN first.

For SVN select 'Projects from CVS'.


You will need to enter the location of the repository. Use

URL svn+ssh://
user your cern user ID
password you cern password


In the next step you can specify the name of the project. Follow the import wizard to the end.


The repository contains Eclipse configuration files and the project will start building when imported. However, the standard recipe includes tcmalloc, a library for performance analysis. You will have to either remove it in the linker step (linker under libraries) or download the Google Performance tools (described here)

Submit changes to CVS/SVN

The easiest way to commit multiple files and to check for new files in the repository is to use the Synchronise Project View. To get there right-click on your project, select Team->Synchronise Project with repository:


Once you switch to the Synchronise View you will see all the changes others did to the project and your own. You can compare the changes of a specific file by double-clicking on it. This is especially useful if a conflict occurs, i.e. when a file you were working on changed in the meanwhile. You can then merge the changes together and update the file.


CUTE (C++ Unit Testing Easier)

Unit tests are very important to maintain the functionality intended. Changes in the code can be non-trivial and affect other parts. Therefore it is alway important to run the tests as well. The way it is done in Eclipse is to install the CUTE plugin which will help to run the tests and visualise the test results

Install Cute plugin

Installation instructions can be found here.

Run Unit Tests

Since the project in the repository already contains the build for CUTE, you can start it right away. Go to Run Configurations:


There go on CUTE Test and click on 'Run':


Eclipse will display results like this:


Google Performance Tools (optional)

Code formatter

Optional plugins


To install SVN perform the same steps as in Install PyDev. Select 'Helios -' from the available update sites. Install_SVN.png

First time you attempt to use SVN or when you restart Eclipse you will be prompted to choose your SVN connector. To get the right one, check first which SVN version is installed on your machine:

svn --version

I recommend the usage of the Java only connector (SVN Kit, works on all OSs):


Eclipse will now install the SVN connector and prompt you for a restart.

Linux profiling Tools (Linux only)

Remote System Explorer

Since we usually end up transferring the code to a remote machine to perform the analysis. Also you might want to edit a single file, i.e. changing the input file, on a remote machine. This is where the Remote System Explorer comes in handy. It allows you to open and edit either single remote files or whole folder structures when used as remote projects.

You can find it the same way as SVN ( here) under "General Purpose Tools".

Addtional plugins, which I haven't tested myself yet, can be obtained from the CUTE update page. They include the Remote Compiler and Debugger.


How to link other projects within Eclipse (Example TopQuarkAnalysis/TopHitFit)

Get Project

  • create an empty C++ project with the name TopQuarkAnalysis
  • in the project wizard choose shared library as the project type (Shared Library -> Empty Project)
  • follow the instructions in Import Project to import the TopHitFit package from CVS.
  • use specified module name: CMSSW/TopQuarkAnalysis/TopHitFit
  • use: Check out into existing project then pick TopQuarkAnalysis
  • Finish the import


You won't be able to compile as:
  • CMSSW used the complete Project path (TopQuarkAnalysis/TopHitFit)
  • some files depend on CMSSW

What you need to do:

  • fix the include path: * Right-click on project and go to properties * go to 'C/C++ General -> Paths and Symbols -> Includes' * add your workspace path as an include directory to ALL configurations for C++ (i.e. if path to project is /home/user/workspace/TopQuarkAnalysis use /home/user/workspace/)
  • exclude CMSSW dependet files from build: * Right-click on project and go to properties * go to 'C/C++ General -> Paths and Symbols -> Source location' * select the project and click on 'Edit Filter' * click on 'Add Multiple' and select all files fitting TopQuarkAnalysis/TopHitFi/src/Pat* as well as the TopQuarkAnalysis/TopHitFi/plugins folder

If you try to compile at this point you might get an saying that you have to recompile with the 'fPIC' option. To enable this:

  • Right-click on project and go to properties
  • go to 'C/C++ Build -> Settings'
  • select C++ complier and go to 'Miscellanious' option
  • enable 'Position independent Code (fPIC)' checkbox. If not available add the option manually (-fPIC) in the text-box

Link project to BristolAnalysisTools

  • add the include path: * Right-click on project and go to properties * go to 'C/C++ General -> Paths and Symbols -> Includes' * add your workspace path as an include directory to ALL configurations for C++ (i.e. if path to project is /home/user/workspace/TopQuarkAnalysis use /home/user/workspace/)
  • Link to the library: * Right-click on project and go to properties * go to 'C/C++ General -> Paths and Symbols -> Library Paths' * add 'TopQuarkAnalysis/Release' to all configurations * In 'Libraries' add 'TopQuarkAnalysis'

-- LukasKreczko - 04-Sep-2011

  • CUTE test results:
Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng AddPydev.png r1 manage 46.9 K 2011-03-07 - 14:59 LukasKreczko add pydev update site
PNGpng CheckOutAs.png r1 manage 48.1 K 2011-03-07 - 16:58 LukasKreczko check out CVS project as
PNGpng CheckoutAsSVN.png r1 manage 59.4 K 2011-03-09 - 22:43 LukasKreczko check out SVN project as
PNGpng CheckoutSVN.png r1 manage 64.3 K 2011-03-09 - 22:42 LukasKreczko check out from SVN
PNGpng Checkout_from_CVS.png r1 manage 57.1 K 2011-03-07 - 16:58 LukasKreczko check out from CVS
PNGpng CuteTestResults.png r1 manage 32.6 K 2011-03-10 - 19:04 LukasKreczko CUTE test results
PNGpng DownloadEclipse.png r1 manage 15.2 K 2011-02-15 - 20:32 LukasKreczko Download Eclipse
PNGpng DownloadEclipseMAc.png r1 manage 12.9 K 2011-02-15 - 20:33 LukasKreczko Download Eclipse MAC
PNGpng EclipseEnvironment.png r1 manage 91.2 K 2011-02-16 - 13:20 LukasKreczko Eclipse Environment settings
PNGpng EclipseFirstStart2.png r1 manage 222.5 K 2011-02-16 - 13:14 LukasKreczko  
PNGpng EclipseIndexer.png r1 manage 137.8 K 2011-02-16 - 13:24 LukasKreczko Edit indexer
PNGpng EclipseNewProject.png r1 manage 51.4 K 2011-02-16 - 13:17 LukasKreczko Create new C++ project
PNGpng EclipseNewProject_.png r1 manage 67.0 K 2011-02-16 - 13:16 LukasKreczko Create new C++ project
PNGpng EclipsePreferences.png r1 manage 110.7 K 2011-02-16 - 13:19 LukasKreczko Eclipse Preferences
PNGpng ImportFromCVS.png r1 manage 32.6 K 2011-03-07 - 16:59 LukasKreczko import project from CVS
PNGpng ImportProject.png r1 manage 79.5 K 2011-03-07 - 16:58 LukasKreczko import project
PNGpng InstallNewPlugins.png r1 manage 125.9 K 2011-03-07 - 14:59 LukasKreczko Install new plugin
PNGpng Install_SVN.png r1 manage 95.7 K 2011-03-09 - 21:11 LukasKreczko How to install SVN
PNGpng ProjectFirstRun.png r1 manage 26.5 K 2011-02-16 - 13:18 LukasKreczko Run the C++ project for the first time
PNGpng ProjectFromSVN.png r1 manage 38.0 K 2011-03-09 - 22:43 LukasKreczko import project from SVN
PNGpng ProjectIncludes.png r1 manage 126.0 K 2011-03-07 - 12:36 LukasKreczko includes for ROOT project
PNGpng ProjectLibraryPath.png r1 manage 98.4 K 2011-03-07 - 12:36 LukasKreczko Libarary path for ROOT project
PNGpng ProjectLinkerSettings.png r1 manage 115.5 K 2011-03-07 - 12:37 LukasKreczko Linker settings for ROOT project
PNGpng ProjectPreferences.png r1 manage 121.2 K 2011-03-07 - 12:37 LukasKreczko project preferences
PNGpng ProjectRunConfigurations.png r1 manage 144.2 K 2011-03-07 - 12:38 LukasKreczko run configuration
PNGpng ProjectRunEnvironment.png r1 manage 71.2 K 2011-03-07 - 12:39 LukasKreczko environment variables for running ROOT project
PNGpng PyDevInterpreter.png r1 manage 92.7 K 2011-03-07 - 15:12 LukasKreczko set up Python interpreter
PNGpng PyDevInterpreter_lastStep.png r1 manage 74.7 K 2011-03-07 - 15:12 LukasKreczko Set up PYTHONPATH
PNGpng PydevProject.png r1 manage 44.2 K 2011-03-07 - 15:12 LukasKreczko create PyDev project
PNGpng RunConfigurations.png r1 manage 86.7 K 2011-03-10 - 18:55 LukasKreczko run configurations
PNGpng RunTests.png r1 manage 100.2 K 2011-03-10 - 18:56 LukasKreczko run tests
PNGpng SVNConnector.png r1 manage 102.1 K 2011-03-09 - 21:37 LukasKreczko Choose your SVN connector
PNGpng SelectPydev.png r1 manage 22.0 K 2011-03-07 - 15:00 LukasKreczko select PyDev
PNGpng SynchroniseView.png r1 manage 173.8 K 2011-03-10 - 17:18 LukasKreczko Synchronise View
PNGpng Synchronise_Project_.png r1 manage 133.1 K 2011-03-10 - 17:18 LukasKreczko Synchronise project with repository
Edit | Attach | Watch | Print version | History: r23 < r22 < r21 < r20 < r19 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r23 - 2016-06-20 - LukasKreczko
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CMSPublic All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback