Compile CERN ROOT 6 with FFTW and Debug symbols on Linux

Petr Stepanov
2 min readFeb 16, 2020

As opposed to the version 5 of CERN ROOT, version 6 introduced a much easier build from source procedure. The libraries that ROOT does depend on, such as FFTW are integrated into the source code. User does not have to manually download and build them. Instead, ROOT can take care of that itself.

Before we start building, please refer to the official ROOT website and install the build prerequisities.

Ubuntu prerequisities seem to be up-to-date. Unfortunately the prerequisities for the recent Fedora linux versions are missing. Below please find the complete list of the Fedora 31 packages needed to build CERN ROOT 6.

Required packages:

sudo dnf install git cmake gcc-c++ gcc binutils libX11-devel libXpm-devel libXft-devel libXext-devel

Optional packages:

sudo dnf install gcc-gfortran openssl-devel pcre-devel mesa-libGL-devel mesa-libGLU-devel glew-devel ftgl-devel mysql-devel fftw-devel cfitsio-devel graphviz-devel avahi-compat-libdns_sd-devel python-devel libxml2-devel openldap gsl-devel

Please install both lists of packages. Next, we can download the source code either from the ROOT website or directly from GitHub. I like to have things organized. Usually keep my ROOT source files in the ~/Downlonads folder.

mkdir -p ~/Downloads && cd ~/Downloads
git clone https://github.com/root-project/root.git

It’s a good idea to keep compiled ROOT libraries in ~/Applications following the macOS convention. Create the directory for the build:

mkdir -p ~/Applications/root && cd ~/Applications/root

Configure the ROOT build depending on your needs. Usually I include the FFTW library for the RooFit’s FFT3 convolution. If you are developing applications with ROOT libraries you will apparently need to compile ROOT with debug symbols:

cmake -Dbuiltin_fftw3=ON ~/Downloads/root-source-folder
cmake -DCMAKE_BUILD_TYPE=Debug ~/Downloads/root-source-folder

Now we proceed with building ROOT. It’s important to specify number of CPU cores to reduce the compile time. Here we use the nproc command to figure out the number of cores:

cmake --build . -- -j`nproc`

This process will take a while. Finally, in order to set up the environment libraries source thisroot.sh in your configuration script and update your shell script:

echo "source ~/Applications/root/bin/thisroot.sh" >> ~/.bashrc
source ~/.bashrc

Now you can run ROOT by typing root in the command prompt.

In order to prevent accidental change of the ROOT source files remove the write privileges from the source folder and enclosed files recursively:

chmod -R -w ~/Downloads/root-source-folder

--

--

Petr Stepanov

Gamma-spectroscopy. Positron annihilation spectroscopy. M.S. in solid-state physics. PhD in photochemical sciences. Desktop, frontend and iOS developer.