Installing CERN ROOT under Windows 10 with Subsystem for Linux

I am not a coding expert by any means, just a physicist that needs to code some stuff sometimes. Hopefully this helps someone else.

I need to use Windows and GNU/Linux for my work and haven’t been able to pick just one so I am normally running a virtual machine with Ubuntu on my Windows10 host. I’ve avoided a dual boot system since I don’t like partitioning my hard-drive when I don’t have to. Plus, I can share folders across the systems as well as the clipboard, and save my virtual machine state and reload it. However, it’s currently taking up 60 GB of my hard drive, mostly to run CERN ROOT for data analysis and a few other useful Linux tools, and consumes a large fraction of my RAM and CPU resources, such that I can’t run some other large pieces of software in parallel. I’ve not actually tested if Linux for Windows (Beta) is faster or lighter yet.

Update: The speeds seem to be comparable.

Update 10.08.2018: It seems some people have actually read this, and added helpful information in the comments. Thanks, everyone! I’ve added some notes inline as well. I am repeating the installation on a new laptop and will add updates to mirror the changes I found. Current Windows version is 1803.

I also noticed that there is now a preview version compiled under Win32, but this failed to run on my new pc. (preview Windows Visual Studio 2017 (dbg) root_v6.14.02.win32.vc15.debug.exe 167MB)

So let’s try compiling on the linux subsystem.


Install the Windows Subsystem for Linux

You will require Update for Windows 10 Version 1607 or newer for x64-based Systems.

  1. To get Linux on Windows10 running: under Settings → Updates & Security → For Developers → enable Developer Mode
  2. open Control Panel → Programs → Turn Windows features on or off → enable Windows Subsystem for Linux .
  3. Windows will install some files and restart.
  4. You will need to install and run an X-windows server on Windows: Xming official site: http://www.straightrunning.com/XmingNotes/ or vcXsrv: https://sourceforge.net/projects/vcxsrv/ . Either will run in the background in your taskbar. Be sure to add the additional fonts: https://sourceforge.net/projects/xming/files/Xming-fonts/
  5. To run Linux for Windows, from the search window, search for and run “bash.exe”. This will open a terminal window (bash shell) and install Ubuntu for Windows from the Windows Store. Enter a user account name and password when prompted. It shows up in the Start menu later “Bash on Ubuntu on Windows” later. I pinned it to the start menu for quick access. 
    Update 10.08.2018: It seems you can now install many Linux flavours that you like from the Microsoft Store first without executing bash.exe. I chose Ubuntu 18.04 this time for continuity.
  6. Update your distribution. It’s probably a little out of date. It also helped with missing packages.
$ sudo apt update
$ sudo apt upgrade

7. Everything works like Ubuntu 14.04/18.04 now. Execute the following to append the correct display to the .bashrc file. It will allow you to open programs with GUIs. Hint: Ctrl-C to copy and right mouse button to paste.

$ export DISPLAY="localhost:0"
$ echo 'export DISPLAY="localhost:0"' >> ~/.bashrc

Download your preferred version of ROOT from https://root.cern.ch/downloading-root

Skip to to helpful hints at the bottom for additional tips.

Compile ROOT Locally

8. To begin the install of CERN ROOT, first install the basic prerequisites for Ubuntu as shown in https://root.cern.ch/build-prerequisites . In the additional packages, libcfitsio-dev doesn’t seem to work, so I’ve not included it. Execute the following:

to build ROOT 5.34.36 under Ubuntu 14.04

$ sudo apt-get install cmake
$ sudo apt-get install git dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev
//use the following extra packages for Ubuntu 14.04. 
$ sudo apt-get install gfortran libssl-dev libpcre3-dev \
xlibmesa-glu-dev libglew1.5-dev libftgl-dev \
libmysqlclient-dev libfftw3-dev \
graphviz-dev libavahi-compat-libdnssd-dev \
libldap2-dev python-dev libxml2-dev libkrb5-dev \
libgsl0-dev libqt4-dev
$ wget https://root.cern.ch/download/root_v5.34.36.source.tar.gz
$ tar -xzvf root_v5.34.36.source.tar.gz
$ mkdir builddir
$ cd builddir
$ cmake ../root
$ cmake --build .

to build ROOT 6.14.02 under Ubuntu 18.04

$ sudo apt-get install cmake
$ sudo apt-get install git dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev
// use the following extra packages for Ubuntu 18.04.
$ sudo apt-get install gfortran libssl-dev libpcre3-dev libglu1-mesa-dev libglew-dev libftgl-dev libmysqlclient-dev libfftw3-dev graphviz-dev libavahi-compat-libdnssd-dev libldap2-dev python-dev libxml2-dev libkrb5-dev libgsl-dev libqt4-dev libtbb-dev
$ wget https://root.cern.ch/download/root_v6.14.02.source.tar.gz 
$ tar -xzvf root_v6.14.02.source.tar.gz
$ mkdir builddir
$ cd builddir
$ cmake ../root-6.14.02/
$ cmake --build .

9. The previous step will take awhile to finish building ROOT. Once it finishes, execute the following:

$ source ~/builddir/bin/thisroot.sh
$ echo 'source ~/builddir/bin/thisroot.sh' >> ~/.bashrc
$ root

Pre-compiled ROOT

A precompiled release for Ubuntu 14.04/18.04 works. You should make sure you have the prerequisites listed above installed though. Otherwise you will see some errors.

7a. Just unzip the file and source root/bin/thisroot.sh.

//Ubuntu 14.04
$ wget https://root.cern.ch/download/root_v6.09.02.Linux-ubuntu14-x86_64-gcc4.8.tar.gz
$ tar -xzvf root_v6.09.02.Linux-ubuntu14-x86_64-gcc4.8.tar.gz
//Ubuntu 18.04
$ wget https://root.cern.ch/download/root_v6.14.02.Linux-ubuntu18-x86_64-gcc7.3.tar.gz
$ tar -xzvf root_v6.14.02.Linux-ubuntu18-x86_64-gcc7.3.tar.gz

$ source ~/root/bin/thisroot.sh
$ echo 'source ~/root/bin/thisroot.sh' >> ~/.bashrc
$ root

You should now see the ROOT splash screen and the CINT command line.

Helpful Hints

  1. For “better appearance” of TBrowser, edit the “${ROOTSYS}/etc/system.rootrc” file and set “X11.UseXft:” to “yes” (by default it is “no”). Other details in the .rootrc are explained here: https://root.cern.ch/root/html534/guides/users-guide/InstallandBuild.html#file-system.rootrc