Prerequisites:
sudo apt install build-essential git subversion dpkg-dev make g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev
Optional (recommended) prerequisites:
sudo apt install gfortran libssl-dev libpcre3-dev libglu1-mesa-dev libglew-dev libftgl-dev libmysqlclient-dev libfftw3-dev libcfitsio3-dev graphviz-dev libavahi-compat-libdnssd-dev libldap2-dev python-dev libxml2-dev libkrb5-dev libgsl0-dev libqt4-dev
Optionally, install GSL and CASTOR libraries, and Geant4 prerequisites.
Install font server and fonts for ROOT:
sudo apt install xfstt
sudo apt install t1-xfree86-nonfree ttf-xfree86-nonfree ttf-xfree86-nonfree-syriac xfonts-75dpi xfonts-100dpi
service xfstt start
(Source: http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=12627)
Update: cmake-based build
Get ROOT sources as in https://root.cern.ch/get-root-sources:
mkdir ROOT && cd ROOT
git clone http://root.cern.ch/git/root.git
mv root root-sources
mkdir root-build
mkdir root-install
cd root-sources
git tag -l
Choose your preferred version. As an example, v6-14-04:
git checkout -b v6-14-04 v6-14-04
Now build ROOT (ref. https://root.cern.ch/building-root):
cd ../root-build
cmake -DCMAKE_INSTALL_PREFIX=$HOME/ROOT/root-install -DPYTHIA8_DIR=$PYTHIA8 -DPYTHIA8_INCLUDE_DIR=$PYTHIA8/include -DPYTHIA8_LIBRARY=$PYTHIA8/lib/libpythia8.so -DGSL_DIR=/usr/local -Dbuiltin_xrootd=ON -Droofit=ON -Dpythia8=ON ../root-sources
or, to make it use python3 instead, assuming a new installation under ROOT/ROOT-PY3 (source: https://root-forum.cern.ch/t/how-to-properly-install-pyroot-for-python-3/26367):
cmake -DCMAKE_INSTALL_PREFIX=$HOME/ROOT/ROOT-PY3/root-install -DPYTHIA8_DIR=$PYTHIA8 -DPYTHIA8_INCLUDE_DIR=$PYTHIA8/include -DPYTHIA8_LIBRARY=$PYTHIA8/lib/libpythia8.so -DGSL_DIR=/usr/local -Dbuiltin_xrootd=ON -Droofit=ON -Dpythia8=ON -Dpython3=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 ../root-sources
cmake --build . --target install -- -jN
Outdated: make-based build
Get ROOT (last stable version 5.34):
wget ftp://root.cern.ch/root/root_v5.34.14.source.tar.gz
gzip -dc root_v5.34.14.source.tar.gz | tar -xf -
Or get ROOT 5.99:
git clone http://root.cern.ch/git/root.git
cd root && git tag -l
git checkout -b v5-99-05 v5-99-05
Compile ROOT (if you do not need GSL or Pythia, drop the configure arguments):
cd root
./configure --all --with-gsl-incdir="/usr/local/include" --with-gsl-libdir="/usr/local/lib" --enable-pythia8 --with-pythia8-incdir=$PYTHIA8/include --with-pythia8-libdir=$PYTHIA8/lib
make -j N
where N is the number of CPU cores:
cat /proc/cpuinfo | grep 'cpu cores'
For Ubuntu 14.04 you will also need to do:
sudo mkdir /usr/include/freetype && sudo cp /usr/include/freetype2/freetype.h /usr/include/freetype/freetype.h
Setup environment:
echo "source $PWD/bin/thisroot.sh" >> $HOME/.bashrc
source $HOME/.bashrc
Adjust the path to your needs.
Installing a specific ROOT version on LxPlus / Fedora / Red Hat
The newest xrootd-devel (version 3.3) RPMs for Fedora/RedHat/SL do not include the XrdClient/XrdClientConn.hh header file anymore (it was there in version 3.1). There is a transitional package xrootd-private-devel that will install the missing header files into /usr/include/xrootd.
(From http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=16096.)
To avoid compilation errors, do:
./configure --with-xrootd-incdir="/usr/include/xrootd" --with-xrootd-incdir="/usr/include/xrootd"
adding any other user option, for example:
./configure --all --with-xrootd-incdir="/usr/include/xrootd" --with-xrootd-incdir="/usr/include/xrootd" --enable-pythia8 --with-pythia8-incdir=$PYTHIA8/include --with-pythia8-libdir=$PYTHIA8/lib
To use pyroot there are further adjustments to do: follow the instructions on this page.