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. See below.
These instructions are, in principle, specific to Ubuntu 18.04, as of November 2018, 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 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
Next make a directory called root somewhere sensible, and change into it.
Next, clone the ROOT git repository using:
git clone https://github.com/root-project/root.git 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-14-02
Each version is then built in a different directory. In your root directory, create an appropriate directory:
Just to clarify, your directory structure should be:
root/root-git [contains source] root/root-v6-14-02 [will contain build of v6-14-02] 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-14-02) 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. This worked without any problems for ROOT version v6-14-02 and v5-34-38. ROOT v5-34-34 did not work – just use the latest version of ROOT v5.
To actually use ROOT, you need to put the appropriate script in your path. Do this by putting the following in your .bashrc file
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.”
(2019-08-23) Added notes on getting minuit2 to compile with OpenMP support for multi-threaded fitting.
(2019-02-19) Fixed the line adding root thisroot.sh to the .bashrc. Also note that the below works fine but you need to be very careful about which directory you run the commands in – just follow the instructions!
(2019-02-04) It turns out that ROOT v5-34-38 builds quite happily on Ubuntu 18.04, which is rather nice.