Building ROOT from source


ROOT uses the CMake cross-platform build-generator tool as the primary build system.
CMake does not build the project, it generates the files needed by your build tool (GNU make, Ninja, Visual Studio, etc) for building ROOT.

If you are really anxious about getting a functional ROOT build, go to the Quick Start section.
If you are a CMake novice, start on Basic CMake usage and then go back to the Quick Start.
The Options and the Variables section is a reference for customizing your build. If you already have experience with CMake, this is the recommended starting point.


Make sure you have installed all required dependencies before building ROOT.

Quick start

The following are the basic instructions for UNIX-like systems. We will use the command-line, non-interactive CMake interface.

  1. Download and unpack the ROOT sources for a specific release (make sure to download the “Source distribution” and not a binary distribution) or simply clone ROOT’s git repository and check out the branch you would like to build, for example:
    # substitute `v6-22-00-patches` with the patches branch of the latest release
    $ git clone --branch v6-22-00-patches root_src

    In the following we will refer to the directory where ROOT sources are (e.g. root_src above) as <sourcedir>.

  2. Create a directory for the build and a directory for the installation. It is not supported to build ROOT in the source directory. Then change (cd) to the build directory:
    $ mkdir <builddir> <installdir>
    $ cd <builddir>
  3. Execute the cmake command on the shell replacing <sourcedir> and <installdir> appropriately:
    $ cmake -DCMAKE_INSTALL_PREFIX=<installdir> <sourcedir>

    CMake will detect your development environment, perform a series of test and generate the files required for building ROOT. CMake will use default values for all build parameters. See the Build Options and Variables sections for fine-tuning your build This can fail if CMake cannot detect your toolset, or if it thinks that the environment is not sane enough. In this case make sure that the toolset that you intend to use is the only one reachable from the shell and that the shell itself is the correct one for you development environment. You can force CMake to use a given build tool, see the Usage section.

  4. Proceed to use IDE project files or start the build from the build directory, after CMake has finished running:
    $ cmake --build . --target install [-- <options to the native tool>]

    The --build option tells cmake to invoke the underlying build tool (make, ninja, xcodebuild, msbuild, etc). The underlying build tool can also be invoked directly of course, but the cmake --build command is more portable. On UNIX systems (with make or ninja) you can speedup the build with cmake --build . -- -jN where N is the number of available cores.

  5. Setup ROOT in your environment:
    $ source <installdir>/bin/ # or thisroot.{csh,fish,bat} depending on the environment

    To have ROOT setup automatically at each login, that command can be appended to a .profile, .login, .bashrc or equivalent configuration file.


As it makes use of a C++ interpreter, ROOT has somewhat stricter requirements than other C++ libraries: applications that depend on ROOT must be compiled with the same C++ standard with which ROOT was compiled.

Also note that compatibility with compilers shipped with devtoolsets on CentOS or Red Hat is not guaranteed.

ROOT, Python and PyROOT

PyROOT, the set of Python bindings of ROOT, changed its structure and build/installation process in v6.22. In the following the main aspects are summarized for both after and before v6.22.

After v6.22

The main feature introduced in v6.22 concerning the PyROOT build system is the possibility to build for both Python3 and Python2 (MultiPython), available only if the version of CMake used to build is >= 3.14. In the following, build and installation processes both with CMake >= 3.14 and < 3.14 are described.

CMake >= 3.14

In this case, PyROOT libraries are built by default with both Python3 and Python2. For each Python version X.Y used to build PyROOT (e.g. 3.8, 2.7, etc.) the following libraries will appear both in the build directory and in the installation directory:


The following pure Python modules will appear as well:

  • ROOT
  • cppyy
  • cppyy_backend

If no option is specified, PyROOT will be built for the most recent Python3 and Python2 versions that CMake can find. If only one version can be found, PyROOT will be built only for that version. Moreover, for a given Python installation to be considered, it must provide both the Python interpreter (binary) and the development package. To build PyROOT, it is thus suggested to verify that python-dev is present and install it if not.

In order to build with specific Python installations (not necessarily the highest ones) hints to CMake can be provided by using -DPython2_ROOT_DIR=python2_dir and/or -DPython3_ROOT_DIR=python3_dir to point to the root directory of some desired Python installation. Similarly, Python2_EXECUTABLE and/or Python3_EXECUTABLE can be used to point to particular Python executables.

PyROOT can be built with only one version of Python even if multiple installations are present in the system. For this purpose, the option -DPYTHON_EXECUTABLE=/path/to/python_exec must be used to point to the desired Python installation. Note that if PYTHON_EXECUTABLE is specified, neither Python3_EXECUTABLE or Python2_EXECUTABLE will be taken into consideration.

When executing a Python script, the Python version used will determine which version of the PyROOT libraries will be loaded. Therefore, once the ROOT environment has been set (e.g. via source $ROOTSYS/bin/, PyROOT can be used from any of the Python versions it has been built for.


# Specify -DPython3_EXECUTABLE and -DPython2_EXECUTABLE in order not to pick the highest Python3 and Python2 versions
$ cmake -DCMAKE_INSTALL_PREFIX=<installdir> -DPython3_EXECUTABLE=<python3interpreter> -DPython2_EXECUTABLE=<python2interpreter> <sourcedir>
$ cmake --build . --target install [-- <options to the native tool>]
$ source <installdir>/bin/
# ROOT can be imported from both Python versions used to build
$ <python3interpreter>
>>> import ROOT
$ <python2interpreter>
>>> import ROOT

The following other components are built and installed along with PyROOT:

  • TPython: its library ( is built only for the highest Python version that PyROOT is built with. Therefore, in a Python3-Python2 ROOT build, the Python code executed with TPython must be Python3-compliant.
  • JupyROOT: built for both Python3 and Python2, it consists of a library and a pure Python module JupyROOT.
  • JsMVA: it consists of a pure Python module which can be used with both Python versions.

CMake < 3.14

If CMake version is < 3.14, the MultiPython feature is not available. PyROOT will thus be built only for one Python version: this is either the one found by CMake, usually the highest available in the system, or the one provided by setting the variable PYTHON_EXECUTABLE.

Before v6.22

For ROOT <= 6.20, an older version of PyROOT (not based on Cppyy) will be built. This same version can be built also in versions >= 6.22 by specifying -Dpyroot_legacy=ON. In this case the Python version used to build will be by default the one pointed by the executable python. A specific Python installation can be used by setting PYTHON_EXECUTABLE.

Setting the C++ standard

ROOT needs to be configured and built with the same C++ standard as the programs that will make use of it. The relevant cmake flag is CMAKE_CXX_STANDARD. For example, from the command line, the standard can be selected by passing one of 11, 14, 20,… such as -DCMAKE_CXX_STANDARD=14.

ROOT STL backports

ROOT backports certain useful C++ standard library features to make them available in C++11, for example std::make_unique and std::string_view. The backports can be found here in the reference guide. The backports are disabled, falling back to the actual C++ standard library implementation if it provides it, depending for instance on the C++ standard ROOT is compiled with and the compiler version.

Enabling experimental features, aka ROOT7

New and improved versions of standard ROOT components are being implemented under codename ROOT7.

Turning on C++14 (see Setting the C++ standard) or higher will automatically enable ROOT7. Alternatively, you can explicitly enable ROOT7 with -Droot7=ON, which will in turn set the standard to C++14 if a value was not already specified by the user.

Building ROOT with CUDA support

To build ROOT with CUDA support, you need to have Nvidia’s CUDA Toolkit installed, and optionally Nvidia’s Cudnn library. The relevant CMake options to set are CMAKE_CUDA_HOST_COMPILER (usually set to the same as CMAKE_CXX_COMPILER), and CMAKE_CUDA_STANDARD. Starting with ROOT 6.20.06 it is possible to set CMAKE_CXX_STANDARD and CMAKE_CUDA_STANDARD to different values to allow to compile ROOT with C++17 while CUDA code with C++14 when using CUDA 9 or 10. In addition to these options, the relevant ROOT build options to enable are -Dcuda=ON -Dcudnn=ON -Dtmva-gpu=ON.

System-wide installation

There are two main methods of installing ROOT from source: location independent and fixed location. The former is advised for a personal installation of ROOT, while the latter for a system-wide installation. Both require to set the CMAKE_INSTALL_PREFIX variable at configuration time (its default is /usr/local if unset). The mode of installation is controlled via the gnuinstall option during configuration.

Location Independent Installation (gnuinstall=OFF)

This is the configuration used by the binary releases on the website. This method requires setting environment variables such as PATH, LD_LIBRARY_PATH, and PYTHONPATH. This is usually done by sourcing the script bin/ or equivalent for your shell from the installation directory. The installation can be done by running

$ cmake --build . --target install

from the build directory. If ROOT is built with -Drpath=ON, then it is usually not necessary to set LD_LIBRARY_PATH after installation. It is also important to note that with this method it is usually not possible to customize installation paths like CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_LIBDIR, etc.

Fixed Location Installation (gnuinstall=ON)

The fixed location installation method is enabled with -Dgnuinstall=ON at configuration time, which then also allows the tuning of destinations for the various components by setting the variables CMAKE_INSTALL_xxxDIR, where xxx is BIN, LIB, INCLUDE, etc. The full list is available in cmake/modules/RootInstallDirs.cmake inside the repository and also in the list of variables below. The fixed location installation method does not require setting any environment variables when ROOT is installed into default system paths (e.g. /usr, /usr/local). However, if CMAKE_INSTALL_LIBDIR is a directory that is not searched for by the linker, it is recommended to enable -Drpath=ON or to add CMAKE_INSTALL_LIBDIR to /etc/ in order to avoid having to set LD_LIBRARY_PATH to be able to run ROOT. Nevertheless, it may still be necessary to set PYTHONPATH with this method if PyROOT is not installed into one of the system paths searched for by Python (run python -m site to see this list of paths). This can be done with export PYTHONPATH=$(root-config --libdir) if root-config is already in your PATH.

All build options

Each build option is a boolean variable that can be turned ON or OFF. The current value is recorded in the CMake cache (CMakeCache.txt file on the build directory) and therefore it is not needed to be specified on the cmake command each time. Please note that some of the options might be turned OFF automatically for some platforms or if the required external library or component can not be satisfied. The user can view and edit the full list of options using the ccmake utility or cmake-gui for Windows. Note that on Windows some of the options are not yet implemented.

The user can set any CMake variable or option that controls the build process from the cmake command line. Passing cmake -D <var>=<value> creates an entry in the CMake cache. The list of the ROOT-specific CMake options can be found below. Note: Some options have platform-dependent default values (e.g. cocoa is ON on apple)

Build option Effect Default
alien Enable support for AliEn (requires libgapiUI from ALICE) OFF
arrow Enable support for Apache Arrow OFF
asimage Enable support for image processing via libAfterImage ON
builtin_afterimage Build bundled copy of libAfterImage OFF
builtin_cfitsio Build CFITSIO internally (requires network) OFF
builtin_clang Build bundled copy of Clang ON
builtin_davix Build Davix internally (requires network) OFF
builtin_fftw3 Build FFTW3 internally (requires network) OFF
builtin_freetype Build bundled copy of freetype OFF
builtin_ftgl Build bundled copy of FTGL OFF
builtin_gl2ps Build bundled copy of gl2ps OFF
builtin_glew Build bundled copy of GLEW OFF
builtin_gsl Build GSL internally (requires network) OFF
builtin_llvm Build bundled copy of LLVM ON
builtin_lz4 Build bundled copy of lz4 OFF
builtin_lzma Build bundled copy of lzma OFF
builtin_openssl Build OpenSSL internally (requires network) OFF
builtin_pcre Build bundled copy of PCRE OFF
builtin_tbb Build TBB internally (requires network) OFF
builtin_unuran Build bundled copy of unuran OFF
builtin_vc Build Vc internally (requires network) OFF
builtin_vdt Build VDT internally (requires network) OFF
builtin_veccore Build VecCore internally (requires network) OFF
builtin_xrootd Build XRootD internally (requires network) OFF
builtin_xxhash Build bundled copy of xxHash OFF
builtin_zlib Build bundled copy of zlib OFF
builtin_zstd Build included libzstd, or use system libzstd OFF
ccache Enable ccache usage for speeding up builds OFF
cefweb Enable support for CEF (Chromium Embedded Framework) web-based display OFF
clad Build clad, the cling automatic differentiation plugin (requires network) ON
cocoa Use native Cocoa/Quartz graphics backend (MacOS X only) OFF
coverage Enable compile flags for coverage testing OFF
cuda Enable support for CUDA (requires CUDA toolkit >= 7.5) OFF
cudnn Enable support for cuDNN (default when Cuda is enabled) ON
cxxmodules Enable support for C++ modules OFF
dataframe Enable ROOT RDataFrame ON
davix Enable support for Davix (HTTP/WebDAV access) ON
dcache Enable support for dCache (requires libdcap from DESY) OFF
dev Enable recommended developer compilation flags, reduce exposed includes OFF
exceptions Enable compiler exception handling ON
fcgi Enable FastCGI suppport in HTTP server OFF
fftw3 Enable support for FFTW3 ON
fitsio Enable support for reading FITS images ON
fortran Build Fortran components of ROOT OFF
gdml Enable support for GDML (Geometry Description Markup Language) ON
gfal Enable support for GFAL (Grid File Access Library) ON
gnuinstall Perform installation following the GNU guidelines OFF
gsl_shared Enable linking against shared libraries for GSL (default no) OFF
gviz Enable support for Graphviz (graph visualization software) OFF
http Enable suppport for HTTP server ON
imt Enable support for implicit multi-threading via Intel® Thread Bulding Blocks (TBB) ON
jemalloc Use jemalloc memory allocator OFF
libcxx Build using libc++ OFF
macos_native Disable looking for libraries, includes and binaries in locations other than a native installation (MacOS only) OFF
mathmore Build libMathMore extended math library (requires GSL) ON
memory_termination Free internal ROOT memory before process termination (experimental, used for leak checking) OFF
memstat Build memory statistics utility (helps to detect memory leaks) OFF
minuit2 Build Minuit2 minimization library OFF
mlp Enable support for TMultilayerPerceptron classes’ federation ON
monalisa Enable support for monitoring with Monalisa (requires libapmoncpp) OFF
mpi Enable support for Message Passing Interface (MPI) OFF
mysql Enable support for MySQL databases ON
odbc Enable support for ODBC databases (requires libiodbc or libodbc) OFF
opengl Enable support for OpenGL (requires libGL and libGLU) ON
oracle Enable support for Oracle databases (requires Oracle Instant Client) ON
pgsql Enable support for PostgreSQL ON
pyroot Enable support for automatic Python bindings (PyROOT) ON
pyroot_legacy Use legacy Python bindings for ROOT OFF
pythia6 Enable support for Pythia 6.x ON
pythia6_nolink Delayed linking of Pythia6 library OFF
pythia8 Enable support for Pythia 8.x ON
qt5web Enable support for Qt5 web-based display (requires Qt5WebEngine) OFF
r Enable support for R bindings (requires R, Rcpp, and RInside) OFF
roofit Build RooFit advanced fitting package ON
root7 Build ROOT 7 components of ROOT (requires C++14 standard or higher) ON
rpath Link libraries with built-in RPATH (run-time search path) OFF
runtime_cxxmodules Enable runtime support for C++ modules ON
shadowpw Enable support for shadow passwords OFF
shared Use shared 3rd party libraries if possible ON
soversion Set version number in sonames (recommended) OFF
spectrum Enable support for TSpectrum ON
sqlite Enable support for SQLite ON
ssl Enable support for SSL encryption via OpenSSL ON
tcmalloc Use tcmalloc memory allocator OFF
tmva Build TMVA multi variate analysis library ON
tmva-cpu Build TMVA with CPU support for deep learning (requires BLAS) ON
tmva-gpu Build TMVA with GPU support for deep learning (requries CUDA) OFF
tmva-pymva Enable support for Python in TMVA (requires numpy) ON
tmva-rmva Enable support for R in TMVA OFF
unuran Enable support for UNURAN (package for generating non-uniform random numbers) OFF
vc Enable support for Vc (SIMD Vector Classes for C++) OFF
vdt Enable support for VDT (fast and vectorisable mathematical functions) ON
veccore Enable support for VecCore SIMD abstraction library OFF
vecgeom Enable support for VecGeom vectorized geometry library OFF
vmc Build VMC simulation library OFF
webgui Build Web-based UI components of ROOT (requires C++14 standard or higher) ON
win_broken_tests Enable broken tests on Windows OFF
winrtdebug Link against the Windows debug runtime library OFF
x11 Enable support for X11/Xft ON
xml Enable support for XML (requires libxml2) ON
xproofd Enable LEGACY support for XProofD file server and client (requires XRootD v4 with private-devel) OFF
xrootd Enable support for XRootD file server and client ON
  Auxiliary build options  
all Enable all optional components by default OFF
asan Build ROOT with address sanitizer instrumentation OFF
clingtest Enable cling tests (Note: that this makes llvm/clang symbols visible in libCling) OFF
gminimal Enable only required options by default, but include X11 OFF
minimal Enable only required options by default OFF
rootbench Build rootbench if rootbench exists in root or if it is a sibling directory. OFF
roottest Build roottest if roottest exists in root or if it is a sibling directory. OFF
testing Enable testing with CTest OFF

Relevant CMake variables

Here are some of the CMake variables that are used often, along with a brief explanation and ROOT-specific notes. For full documentation, check the CMake docs or execute cmake --help-variable VARIABLE_NAME.

Variable Type Explanation
CMAKE_BUILD_TYPE STRING Sets the build type for make based generators. Possible values are Release, MinSizeRel, Debug, RelWithDebInfo and Optimized. On systems like Visual Studio the user sets the build type with the IDE settings. Default is RelWithDebInfo
CMAKE_INSTALL_PREFIX PATH Path where ROOT will be installed if make install is invoked or the “INSTALL” target is built.
CMAKE_C_FLAGS STRING Extra flags to use when compiling C source files.
CMAKE_CXX_FLAGS STRING Extra flags to use when compiling C++ source files.
BUILD_SHARED_LIBS BOOL Flag indicating if shared libraries will be built. Its default value is ON.
CMAKE_Fortran_COMPILER PATH Full path to the Fortran compiler. Alternatively you can specify the environment variable FC before invoking cmake
CMAKE_C_COMPILER PATH Full path to the C compiler. Alternatively you can specify the environment variable CC before invoking cmake
CMAKE_CXX_COMPILER PATH Full path to the C++ compiler. Alternatively you can specify the environment variable CXX before invoking cmake
CMAKE_INSTALL_BINDIR PATH Install destination for user executables (bin)
CMAKE_INSTALL_LIBDIR PATH Install destination for object code libraries (lib or lib64 or lib/ on Debian)
CMAKE_INSTALL_INCLUDEDIR PATH Install destination for C/C++ header files (include)
CMAKE_INSTALL_SYSCONFDIR PATH Install destination for read-only single-machine data (etc)
CMAKE_INSTALL_MANDIR PATH Install destination for man documentation (DATAROOTDIR/man)
CMAKE_INSTALL_DATAROOTDIR PATH Install directory for read-only architecture-independent data (share)
CMAKE_INSTALL_DATADIR PATH Install destination read-only architecture-independent data (DATAROOTDIR/root)
CMAKE_INSTALL_MACRODIR PATH Install destination for ROOT macros (DATAROOTDIR/macros)
CMAKE_INSTALL_ICONDIR PATH Install destination for icons (DATAROOTDIR/icons)
CMAKE_INSTALL_FONTDIR PATH Install destination for fonts (DATAROOTDIR/fonts)
CMAKE_INSTALL_SRCDIR PATH Install destination for sources (DATAROOTDIR/src)
CMAKE_INSTALL_DOCDIR PATH Install destination for documentation root (DATAROOTDIR/doc/root)
CMAKE_INSTALL_TESTDIR PATH Install destination for tests (DOCDIR/test)
CMAKE_INSTALL_TUTDIR PATH Install destination for tutorials (DOCDIR/tutorials)
CMAKE_INSTALL_ACLOCALDIR PATH Install destination for locale-dependent data (DATAROOTDIR/aclocal)
CMAKE_INSTALL_ELISPDIR PATH Install destination for lisp files (DATAROOTDIR/emacs/site-lisp)
CMAKE_INSTALL_CMAKEDIR PATH Install destination for cmake modules (DATAROOTDIR/cmake)

Additional variables

A number of additional variables to control the way ROOT is built.

Variable Type Explanation
LLVM_BUILD_TYPE STRING Build type for the bundled LLVM. It is used to set the CMAKE_BUILD_TYPE for the /interpreter/ subdirectory

External libraries

ROOT requires a number of external libraries that the CMake system needs to locate. The list of externals depends on the build options that have been enabled. CMake will look for these third party products at a number of standard places in your system but the user can influence the search by setting some environment variables before invoking the CMake command or by setting package specific CMake variables to their exact location.

The actual cached values used by CMake for the exact location of libraries and include files of the used external libraries can be inspected and modified using the ccmake utility.

Package Name Variable Type Description
AfterImage AFTERIMAGE_CONFIG_EXECUTABLE PATH Full path to afterimage-config program
Alien ALIEN_DIR PATH Directory where Alien is installed (-DALIEN_DIR=$ALIEN_DIR/api)
Bonjour BONJOUR_INCLUDE_DIR PATH Directory where to find dns_sd.h
  AVAHI_INCLUDE_DIR PATH Directory where avahi-client/client.h (Linux)
  AVAHI_client_LIBRARY PATH Full path to library
CASTOR CASTOR_DIR PATH Environment variable to the Castor installation.
  CASTOR_INCLUDE_DIR PATH Path to rfio_api.h file
  CASTOR_shift_LIBRARY PATH Full path to shift library
  CFITSIO_INCLUDE_DIR PATH Directory where to find fitsio.h
  CFITSIO_LIBRARIES PATH Full path to cfitsio library
  FFTW_INCLUDE_DIR PATH Directory where to find fftw3.h
  FFTW_LIBRARY PATH Full path to fftw3 library
GraphViz GRAPHVIZ_DIR PATH Installation of GraphViz
  GRAPHVIZ_INCLUDE_DIR PATH Directory where to find graphviz/graph.h
  GRAPHVIZ_CDT_LIBRARY PATH Full path to cdt library
  GRAPHVIZ_GVC_LIBRARY PATH Full path to gvc library
  GRAPHVIZ_GRAPH_LIBRARY PATH Full path to graph library
  GRAPHVIZ_PATHPLAN_LIBRARY PATH Full path to pathplan library
GSL GSL_ROOT_DIR PATH Environment variable to the GSL installation.
  GSL_CONFIG_EXECUTABLE PATH Full path to gsl-config program
Kerberos 5 KRB5_DIR PATH Installation of Kerberos5
  KRB5_INCLUDE_DIR PATH Directory where to find krb5.h
  KRB5_MIT_LIBRARY PATH Full path to k5crypto library
  KRB5_LIBRARY PATH Full path to krb5 library
  KRB5_INIT PATH Full path to kinit program
  LZMA_INCLUDE_DIR PATH Directory where to find lzma.h
  LZMA_LIBRARY PATH Full path to lzma library
MySQL MYSQL_DIR PATH Installation of MySQL
  MYSQL_CONFIG_EXECUTABLE PATH Full path to mysql_config program
  ODBC_INCLUDE_DIR PATH Directory where to find sqlext.h
  ODBC_LIBRARY PATH Full path to libodbc library
Oracle ORACLE_DIR ENV Environment variable to the Oracle installation.
  ORACLE_INCLUDE_DIR PATH Location where to find oci.h
  ORACLE_LIBRARY_OCCI PATH Full path to libocci library
  SQLPLUS_EXECUTABLE PATH Full path to the sqlplus program
OpenGL OPENGL_INCLUDE_DIR PATH Location where to find GL/gl.h
  OPENGL_gl_LIBRARY PATH Full path to GL library
PCRE PCRE_CONFIG_EXECUTABLE PATH Full path to pcre_config program
PostgreSQL POSTGRESQL_INCLUDE_DIR PATH Directory where to find l ibpq-fe.h
  POSTGRESQL_LIBRARY PATH Full path to pq library
Pythia 6 PYTHIA6_LIBRARY PATH Full path to pythia6 library
Pythia 8 PYTHIA8_DIR ENV Environment variable pointing to installation of Pythia8
  PYTHIA8_INCLUDE_DIR PATH Directory where to find Pythia8/Pythia.h
  PYTHIA8_LIBRARY PATH Full path to Pythia8 library
Python PYTHON_EXECUTABLE PATH Python interpreter executable
  PYTHON_INCLUDE_DIR PATH Directory where to find Python.h
  PYTHON_LIBRARY PATH Full path to Python library