Kahibaro
Login Register

Installation

Overview

The installation of ROOT can be done in many ways.

Snap

If you have an Ubuntu-based system, you can simply use install it via snap

sudo snap install root-framework

From Source

Manual Installation

You can also install it from source. The following example is based on Ubuntu 24.04 and ROOT 6.30.02. However, for most of the other version, the commands should not differ significantly.

First, all dependencies have to be installed:

sudo apt install -y dpkg-dev cmake g++ gcc binutils libx11-dev \
libxpm-dev libxft-dev libxext-dev python3 libssl-dev \
libafterimage0 gfortran libpcre3-dev xlibmesa-glu-dev \
libglew-dev libftgl-dev libmysqlclient-dev libfftw3-dev \
libcfitsio-dev graphviz-dev libavahi-compat-libdnssd-dev \
libldap2-dev python3-dev python3-numpy libxml2-dev \
libkrb5-dev libgsl0-dev qtwebengine5-dev nlohmann-json3-dev

In the next step, you can create a folder called root inside your home folder, for example inside another sub-folder software:

export ROOT_DIR=~/software/root/
mkdir -p $ROOT_DIR
cd $ROOT_DIR

Now the source code can be downloaded and extracted:

wget https://root.cern/download/root_v6.30.02.source.tar.gz
tar -xzvf root_v6.30.02.source.tar.gz

Then the build directly has to be created:

mkdir root-6.30.02-build
cd root-6.30.02-build
cmake -DCMAKE_INSTALL_PREFIX=$ROOT_DIR/root-6.30.02-install ../root-6.30.02/
make -j4
make install

The last step is to source the file thisroot.sh

. $ROOT_DIR/root-6.30.02-install/bin/thisroot.sh

In order to start this script automatically in every new session, you can insert this into your .bashrc:

. ~/software/root/root-6.30.02-install/thisroot.sh

With Script

The following script can be used to automatize the installation. You can copy it into a file named root.sh and then run it with . root,sh

#!/bin/bash
VERSION=6.34.06
# Define directory paths
ROOT_DIR=~/software/root/
ROOT_TAR_FILE=$ROOT_DIR/root_v$VERSION.source.tar.gz
ROOT_SRC_DIR=$ROOT_DIR/root-$VERSION
ROOT_BUILD_DIR=$ROOT_DIR/root-$VERSION-build
ROOT_INSTALL_DIR=$ROOT_DIR/root-$VERSION-install
# Expected checksum for the ROOT tar file (replace this with the actual checksum)
EXPECTED_CHECKSUM="a799d632dae5bb1ec87eae6ebc046a12268c6849f2a8837921c118fc51b6cff3"
# Update and Upgrade the System
sudo apt update && sudo apt upgrade -y
# Install dependencies for ROOT and Qt5
sudo apt install -y dpkg-dev cmake g++ git gcc binutils libx11-dev \
libxpm-dev libxft-dev libxext-dev python3 libssl-dev \
libafterimage0 gfortran libpcre3-dev xlibmesa-glu-dev \
libglew-dev libftgl-dev libmysqlclient-dev libfftw3-dev \
libcfitsio-dev graphviz-dev libavahi-compat-libdnssd-dev \
libldap2-dev python3-dev python3-numpy libxml2-dev \
libkrb5-dev libgsl0-dev qtwebengine5-dev nlohmann-json3-dev
# Create ROOT directory
mkdir -p $ROOT_DIR
# Check if the tar file exists and the checksum matches
if [ ! -f $ROOT_TAR_FILE ] || ! echo "$EXPECTED_CHECKSUM $ROOT_TAR_FILE" | sha256sum --check --status; then
    echo "Downloading ROOT source code..."
    wget -O $ROOT_TAR_FILE https://root.cern/download/root_v$VERSION.source.tar.gz
else
    echo "ROOT tar file already exists and checksum matches."
fi
# Extract the tar file
tar -xzvf $ROOT_TAR_FILE -C $ROOT_DIR
# Create a directory for building ROOT
mkdir -p $ROOT_BUILD_DIR
# Configure the build with CMake, including Qt5
cmake -DCMAKE_INSTALL_PREFIX=$ROOT_INSTALL_DIR \
      -B$ROOT_BUILD_DIR \
      -H$ROOT_SRC_DIR
# Compile and install
make -C $ROOT_BUILD_DIR -j$(nproc)
make -C $ROOT_BUILD_DIR install
# Setup the environment (you should add this to your .bashrc)
echo "source $ROOT_INSTALL_DIR/bin/thisroot.sh" >> ~/.bashrc

Views: 37

Comments

Please login to add a comment.

Don't have an account? Register now!