How do I actually install ROOT?


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Ubuntu 20.04
Compiler: Not Provided


My apologies for such a basic question, but how do I actually install ROOT? I’m on Ubuntu 20.04 (the latest release), and I’ve spent the better of 4 days trying to install ROOT. I’ve followed various tutorials online, several guides, and the ROOT documentation. All are slightly different, and none have worked for me. I’ve encountered far too many errors to list here, at various steps of the process. I’ve done a clean install of Ubuntu twice. I’ve spent too much time playing around with this. Can someone tell me how to actually install ROOT for my system? Thanks so much in advance!

I start by installing the package “build-essential”:

sudo apt install build-essential

Then go here:
https://root.cern/build-prerequisites#ubuntu
and install the “required” prerequisites they list (to be safe, even if you won’t be compiling root, as I show here). You can install them one by one or use the “sudo” command they provide (below the list) for the “Required packages”; some will have been installed already with build-essential, so you may want to go one by one (also get the optional packages if you want, but not really needed, unless you know you need them).

Then go here:
https://root.cern/downloading-root
and click on the latest Pro release. As of today, it takes you to v. 6.20/04
https://root.cern/content/release-62004
From there, download the binary package for your Ubuntu and gcc versions. There’s no Ubuntu 20.04 yet but the one for “Ubuntu 19 gcc9.2” works (root_v6.20.04.Linux-ubuntu19-x86_64-gcc9.2.tar.gz).
Extract everything inside, to any folder, e.g.

tar xzvf root_v6.20.04.Linux-ubuntu19-x86_64-gcc9.2.tar.gz /home/myusername

which creates a folder called “root” (you can rename it, e.g. to “root62004”). Then add this line at the end of your /home/myusername/.bashrc file:

source /home/myusername/root62004/bin/thisroot.sh

save it and close the terminal. Of course, change “myusername” and “root62004” in the paths above to whatever is your case. Now every time you open a terminal just type “root” and it should run.

Hi,
the easiest way is probably to install ROOT in a conda environment. From the terminal:

# first install conda (instructions at https://docs.conda.io/en/latest/miniconda.html#linux-installers)
$ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
$ bash Miniconda3-latest-Linux-x86_64.sh # and just follow the instructions on the terminal
# then install ROOT
$ conda create -c conda-forge --name <my-environment> root
$ conda activate <my-environment>

Whenever you want to have ROOT available in a terminal, you have to first give the command conda activate <my-environment>.

The second easiest way, in my opinion, is what @dastudillo described. To summarize the essential steps, that they described nicely in detail above:

  1. install all prerequisites for your platform
  2. download and unpack a pre-compiled binary (no need to compile anything, but make sure you download a “Binary distribution” and not the “Source distribution”)
  3. Whenever you want to have ROOT available in a terminal, you have to first give the command source path/to/unpacked/root/bin/thisroot.sh

Note that we currently do not have pre-compiled binaries for Ubuntu 20.04. I think the ones for Ubuntu 19 should just work.

Very soon we will have an even simpler method (download a root.deb package and apt install root.deb). Stay tuned :smile:

Cheers,
Enrico

You can easily get the list of available binary releases for e.g. “Ubuntu 20”:

curl -s -l "https://root.cern/download/?C=M;O=A" | grep -i "ubuntu*20" | sed -e '{s/.*\(root.*gz\).*/\1/}'

BTW. Immediately after:

do not forget to execute: sudo apt-get purge root*

Just want to add onto what others have posted. Here’s the whole process that I went through to install root onto Ubuntu 20.04.
First, download the prerequisite from https://root.cern.ch/build-prerequisites#ubuntu for ubuntu. The two lines of code you will need are:

  1. sudo apt-get install git dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev
  2. 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
    You may encounter some problems with the libqt4-dev since ubuntu 20.04 doesn’t carry qt4 anymore. However, if you need it (I think Geant4 uses it), then replace libqt4-dev with qt5-default

Once that’s done, you can then start with installing root. Go to https://root.cern.ch/content/release-62004 and download the source file (root_v6.20.04.source.tar.gz). Next, use the following commands to install it, starting from the $HOME directory:

  1. cd $HOME
  2. mkdir Cern_Root
  3. cp Downloads/root_v6.20.04.source.tar.gz Cern_Root/
  4. cd Cern_Root
  5. tar -zxvf root_v6.20.04.source.tar.gz
    You should now have a new directory inside of Cern_Root called root-6.20.04
  6. cd root-6.20.04
  7. mkdir root-build
  8. mkdir root-install
  9. cd root-build
  10. cmake …
  11. cmake -Dall=on .
  12. cmake -DCMAKE_INSTALL_PREFIX=~/Cern_Root/root-6.20.04/root-install .
  13. make -jN (where N is the number of cores your machine has, the more core you provide, the quicker this step will be)
  14. make install
  15. cd …/root-install/bin
  16. . thisroot.sh
  17. root

At this point, you should be able to start using root. However, if you want to be able to run root anywhere (at this moment, if you close the terminal, start a new one, it will not recognize the command root), you need to add some stuff onto your bash like follow:

  1. Open a new terminal
  2. cd $HOME
  3. gedit .bashrc
  4. go to the bottom and add the following:

#For Cern ROOT

export ROOTSYS=$HOME/Cern_Root/root-6.20.04/root-install/

export PATH=$PATH:$ROOTSYS/bin

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib

When you’re done, save and close it. Open a new terminal, then type in the command “root” to see if it works. Hope this helps!

Try (in case of problems, inspect the three created “*.out.txt” files):

# ... assuming you are using a bash like shell ...
# cd /wherever/you/want/to/build/it
VERSION=6.20.06 # which ROOT version should be downloaded and built
rm -rf root-${VERSION} root-build root-install # cleanup
wget -c https://root.cern/download/root_v${VERSION}.source.tar.gz
tar -zxf root_v${VERSION}.source.tar.gz
mkdir root-build
cd root-build
cmake -DCMAKE_INSTALL_PREFIX=${PWD}/../root-install -Dall=ON ../root-${VERSION} 2>&1 | tee -a cmake.out.txt
nice make -j `nproc` 2>&1 | tee -a make.out.txt
nice make install 2>&1 | tee -a make.intall.out.txt

BTW. Do not modify ROOT related environment variables manually. Always use:

source /full/path/to/your/root/bin/thisroot.sh # setup your ROOT

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

I’ve created some unofficial DEB packages for Ubuntu and Debian to make it easier for users to install.

You can install it like shown below and no setup is required to use ROOT after that.

$ wget https://cern.ch/amadio/root/root_6.22.00_ubuntu20_amd64.deb
$ sudo apt install ./root_6.22.00_ubuntu20_amd64.deb

If you later want to uninstall:

$ sudo apt remove root && sudo apt autoremove

Cheers,

3 Likes