ROOT is a modular scientific framework software used by CERN to do analysis. This framework is very common among High Energy Physics reseachers. This post explains the installation procedure of CERN ROOT and also enabling the various libararies which may be required later. You can learn more about ROOT at cern website.
We are going to install ROOT 6.10.04 in Ubuntu 18.04 which is a latest version of Ubuntu currently available. Many softwares have been upgrade to higher versions in Ubuntu 18.04 like Python3 and gcc 7 etc.
Downloading ROOT Source files:
You can used prebuild binary distribution which do not need compilation but here we are going to build ROOT from source file. You can find all the version of root at https://root.cern.ch/releases . Click on Release 6.10/04 – 2017-07-28 which will take you to a webpage where you can find source as well as binary files for different distribution of Linux. Here you need to download source file named root_v6.10.04.source.tar.gz .
I personally install all this software in a separate folder named “Products”, so I will extract this file and put the folder in this Products folder. You can extract the tar file by typing following command in terminal :
tar -xvzf root_v6.10.04.source.tar.gz root-6.10.04/
Now, you will get a folder named root-6.10.04, which contains the source files. You can read the installation procedure in the file “INSTALL” in “README” folder. We need to install prequisites before we start installing the ROOT.
Prequisites for ROOT Installation:
There are many softwares and libraries which should be preinstalled on your system for installation of ROOT. The list of prequisites can be found at https://root.cern.ch/build-prerequisites . You can install prequisites by typying following into the terminal (Ctrl + Alt + T):
sudo apt-get install git dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev
The above libraries will be sufficient for ROOT installation but if you want you can install few optional also, which may be useful later:
sudo apt-get install gfortran libssl-dev libpcre3-dev \ xlibmesa-glu-dev libglew1.5-dev libftgl-dev \ libmysqlclient-dev libfftw3-dev libcfitsio-dev \ graphviz-dev libavahi-compat-libdnssd-dev \ libldap2-dev python-dev libxml2-dev libkrb5-dev \ libgsl0-dev libqt4-dev
Installing ROOT and enabling all libraries
It is recommended to build the ROOT in a separate folder other than the source folder. Hence, we will create a directory (folder) called “root” in the directory where root-6.10.04 is already present.
mkdir root cd root
Now you are in root directory and ready to build ROOT. The ROOT has provided you options to enable many libraries which are disabled by default. If you want to use them later in your project, you should enable them now. Suppose you want to enable “mathmore” library then you should used “cmake ../root-6.10.04 -Dmathmore=ON” . You can see the complete list of libraries and their default value at https://root.cern.ch/building-root.
We want to install all the libraries, so that we don’t have to worry later when we need some new library. We can use “-Dall=ON” as following:
cmake ../root-6.10.04/ -Dall=ON
If everything goes right, you will see no errors and all the files will be copies to this current directory. Now, you should build ROOT using the following command where “-j3” means that I want my 3 cores of CPU to be used in this build. Please check the number of cores in you system by command “nproc” and use that. I have 4 cores in my laptop but I want to do something else during the installation, hence I used only 3 cores. If you go without “– -j3” then the installation will use only one core and installation will take longer.
cmake --build . -- -j3
With the 3 cores, the installation took about 2 hours to complete. This installation time may vary depending upon system configuration. Now, type the following command before you use root.
Now, your ROOT is ready for use and you can check by typing “root”.
A ROOT environment will open in terminal with the logo of ROOT. Currently the ROOT can be accessed only form the current folder. For ROOT to work from all the directories, you need to modfiy the “.bashrc” file.
First get out of the ROOT enviroment by typing:
Now you need to know the path of current root directory which can be obtained by “pwd”.
Here, we get something like this
This path should be used to define “ROOTSYS”. Now open the .bashrc file.
Paste the following at end of the .bashrc file:
# For ROOT export ROOTSYS=/home/anil/Products/root export PATH=$ROOTSYS/bin:$PATH export LD_LIBRARY_PATH=$ROOTSYS/lib/:$LD_LIBRARY_PATH
You should replace the path in red color with your path obtained from command “pwd”. Now, you can use ROOT in any folder.
You can also watch following video tutorial for installing ROOT. If you have any question, you are free to use our comment box.