Installing CERN ROOT in Windows Subsystem for Linux (WSL)

Petr Stepanov
3 min readJan 23, 2020
GUI ROOT application running on Windows 10 in WSL

It’s been a while since Microsoft introduced a Windows Subsystem for Linux (WSL) feature for Windows 10. It provides a compatibility environment that allows Linux tools and programs to run inside of Windows. Once you install it you get access to a terminal window, where you can run bash scripts, compilers and any linux applications.

Why WSL is a good option for ROOT-based applications?

In Bowling Green State University I developed a number of CERN ROOT based C++ applications that were compiled and linked with GNU Makefiles.

MacOS and Linux operation systems both evolved from the UNIX family. They have different compilers installed by default, namely clang on macOS and gcc in Linux. Nevertheless both operation systems support GNU Autotools environment. So it is possible to compile and install the project with the same code base with some conditionals in the Makefile.

Microsoft windows not only has a different compiler (Microsoft C/C++ Optimizing Compiler cl) but also has its own make utility, NMAKE — which has a different syntax compared to GNU make.

Recently ROOT v6 introduced support for Windows. Unfortunately, it is not clear enough how to compile and link programs with multiple sources that require generation of dictionaries and shared library. There seem to be no examples on how to set up a Visual Studio project.

Technically is possible to use cross-platform build systems, like CMAKE. It generates a platform-specific Makefile which is processed by the corresponding compiler. The question about a CMAKE makefile was posted on the ROOT forum. But unfortunately there does not seem to be a definitive answer for it.

Therefore, the opportunity to take advantage of the WSL, compile and finally run CERN ROOT programs on windows with regular GNU Makefiles seems to be very promising.

By the way, now that we have Crostini it is possible to run ROOT apps on a Chromebook. Think about it :-)

How to set up Windows Subsystem for Linux

First, make sure your Windows 10 system is up-to date. Go to Start → Settings → Update and Security → Windows Update. Check and install all new system updates.

Enable “Developer mode” in Windows. Open Start → Settings → Update and Security → For developers. This will let us use the Linux Bash shell environment.

Install Windows Subsystem For Linux. Feature is located in Start → Windows System → Control Panel -> Programs and Features -> Turn Windows features on or off. Mark the item for installation and restart your computer after install is complete.

Install Ubuntu linux. Open “http://aka.ms/wslstore" in your browser and proceed with install. I recommend installing Ubuntu linux as the most popular distribution. Run Ubuntu from menu Start → Ubuntu.

Create a new user in Ubuntu. On a first start Ubuntu will automatically ask you to do so. It will add the new user to `sudo` group and set it as a default user. Next, update Ubuntu. In Terminal type:

sudo apt-get update && sudo apt-get upgrade

Set the default X server display by setting the DISPLAY environment variable:

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

In order to get GUI applications to work we will need to install libtiff-tools package in Ubuntu terminal:

sudo apt-get install libtiff-tools

Next install Xming — a Windows alternative to the linux X.Org Server. Download binaries from following location https://sourceforge.net/projects/xming/. Install the Xming server itself as well as the Xming-fonts package to ensure the correct rendering of the linux fonts.

It is a good idea to autostart Xming on the Windows startup. Run Start → Xming → XLaunch and follow the wizard selecting default settings. Then add Xming to the startup applications. Open startup applications folder by typing following command in the Windows command prompt:

explorer %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup

Drag the Xming shortcut from the start menu into the File Explorer’s window.

Next, follow the regular directions on installing the CERN ROOT on Ubuntu linux in my previous article.

Tip: your linux hard drive on the windows machine is located in:

C:\Users\your-username\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs

Good luck with your projects.

--

--

Petr Stepanov

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