CERN ROOT on Ubuntu 22.04

Occasionally someone asks me how to install CERN ROOT. If you are reading this, probably it was you.

Sometimes it is me, but more than likely it was you. For the record, I don’t know how to install CERN ROOT, but at some point in the past I did.

These instructions are, in principle, specific to Ubuntu 22.04, as of February 2023, and ROOT v6+. I found some helpful notes here, though they don’t use git.  First, install the required prerequisites.

sudo apt-get install git dpkg-dev cmake g++ gcc binutils \
libx11-dev libxpm-dev libxft-dev libxext-dev

And then, just to be sure, install some more prerequisites.

sudo apt-get install gfortran libssl-dev libpcre3-dev \
xlibmesa-glu-dev libglew-dev libftgl-dev \
libmysqlclient-dev libfftw3-dev libcfitsio-dev \
graphviz-dev libavahi-compat-libdnssd-dev \
libldap2-dev libxml2-dev libkrb5-dev \

Next make a directory called root somewhere sensible, and change into it.

mkdir root
cd root

Next, clone the ROOT git repository using:

git clone root-git

Using git makes it much easier to change ROOT version should you need to. Cloning the repository will take a little. Make a cup of tea. Pontificate on the meaning of life. Write a sonnet. Make another cup of tea. Write a blog post on how to install ROOT. Wait.

The folder root-git contains the git tree. To install different versions, first, in the root-git directory checkout, the desired version from the git repository.

git checkout v6-26-10

Each version is then built in a different directory. In your root directory, create an appropriate directory:

mkdir root-v6-26-10

Just to clarify, your directory structure should be similar to:

root/root-git [contains source]
root/root-v6-26-10 [will contain build of v6-26-10]
root/root-v5-34-38 [will contain build of v5-34-38]
root/root-vOTHER [will contain build of some other version]

Then move into the appropriate build directory and run cmake:

cmake ../root-git/ -Dall=ON -Dminuit2_omp=ON

The root-git option tells cmake where the source directory is, and -Dall=ON makes sure everything you might ever need gets built.  The miniut2_omp option should build the Minuit2 library with OpenMP support for parallel fitting – use this if you need it. If you see errors relating to CMakeCache.txt, just follow the instructions, deleting the appropriate files in the source directory, and run cmake again. If you delete the wrong file, just use:

git checkout -f

to get it back.

Next, in the build directory (root-v6-26-10) just run

cmake --build . -- -j2

where 2 is the number of CPU cores to use – you can use more if you have them. It will still take a long time.

To actually use ROOT, you need to put the appropriate script in your path. Do this by putting the following in your .bashrc file

source /dir/root/root-v6-26-10/bin/

where dir is the path to the root top directory.

So there you go. ROOT is installed. To quote Douglas Adams, “Anything you can’t cope with is therefore your own problem.”

(2023-02-16) Some updates to required packages.

Leave a Reply