Install ROOT and Geant4 on Windows WSL
CVMFS
A collection of ready to use software, including ROOT and Geant4, is published by the Worldwide LHC Computing Grid (WLCG). These releases are catalogued here: lcginfo.cern.ch (CERN computing account required). CVMFS downloads and caches data on demand, making it easy to try different versions, yet fast to
They are distributed via the CERN Virtual File System (CVMFS). Some platform specific prerequisites are needed, these are available in a meta-package for most operating systems called HEP_OSlibs. On the readme for your distribution, there will be instructions on how to install the package.
CVMFS can be set up natively following the instructions at cvmfs.readthedocs.io. Alternatively, you can use docker to run a CVMFS container side by side in WSL. Docker desktop can be installed following docs.docker.com. A CVMFS container can be set up with:
docker run -d --name cvmfs -e CVMFS_CLIENT_PROFILE=single -e CVMFS_REPOSITORIES=sft.cern.ch,geant4.cern.ch,sft-nightlies.cern.ch -e CVMFS_QUOTA_LIMIT=25600 --cap-add SYS_ADMIN --device /dev/fuse --volume /mnt/wsl/cvmfs:/cvmfs:shared cvmfs/service:latest
The docker CVMFS_REPOSITORIES variable can be changed, e.g. if you need access to atlas.cern.ch
. CVMFS_QUOTA_LIMIT is the size of the internal cache in MiB ROOT + GEANT will use ~5GiB so make sure to allow more than that else there will be significant churn in the cache. With a name
being provided, the container can be started again later with just docker run cvmfs
. If settings need to be changed or the image updated, just destroy the image (docker stop cvmfs; docker rm cvmfs
) and re-create as above.
With CVMFS and HEP_OSlibs set up, releases can be used with e.g.: source /cvmfs/sft.cern.ch/lcg/views/setupViews.sh LCG_104 x86_64-el9-gcc13-opt
(Omitting the release and platform triple will print available builds) This is available on the cluster for batch running and the workstations for general use.
Native installation
Windows 10 / 11 with WSL (Updated 4.12.2022)
- Running ROOT inside widows is not advises
- Instead, use Windows 10 / 11 with WSL (Windows Subsystem for Linux) and load Ubuntu in there
- Then you will have an Ubuntu session inside Windows
- See these notes Root inside WSL
Check the C++ and C Compiler Works
- To make a Hello-World program Take this text fragment into nedit,
then save it as Hello-World.cc
- Then issue
g++ Hello-World.cc -o Hello-World
- and run by saying
Hello-World
- Then issue
Now install ROOT
- Download the ROOT source from http://root.cern.ch/
- Use the latest production version, which is 5.16/00 at the time of writing this document.
- Now, install ROOT. "cd" to the parent dir of where ROOT should be installed so "cd /cygdrive/c/" to have ROOT in /cygdrive/c/root). Open a cygwin bash shell, unpack root (assuming you downloaded ROOT to C:\install) by typing
tar xzf /cygdrive/c/install/root_v...win32gcc.tar.gz
- The environment variables like PATH must be set properly (seee the note on the .bashrc file above)
export ROOTSYS=/<where you instlled root> export PATH=$ROOTSYS/bin:$PATH export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH
- Building ROOT with cygwin/GCC consists of two steps:
- First, you need to initialize the build system (configure), telling it that we build for win32gcc then the build system needs to compile everything (via make). I will assume that your ROOT sources reside in C:\INSTALL - just as an example. We will build ROOT in C:\root - but you can do this anywhere you want, e.g. in /usr/shared (as long as the directory name does not contain spaces like Program\ Files). Also, the Windows environment variables TMP, TEMP, TMPDIR may not contain spaces, otherwise make fails when it tries to build the library "libfreetype.a" (thanks to Stilianos Kesisoglou for providing this hint).
- Second build (compile and link) root
- Third, you make the map.
- Open a cygwin bash shell .....
cd /cygdrive/c ./configure win32gcc make make map
- After about 30 minutes to an hour you have the full glory of root available for use! Check it works .... Open a cygwin X-shell ... and type root.
Issues
- Root version 4.05
- If it gives an error with the file wingcc, then find an updated version on the web.
- Root version 5.08
- The above problem has gone
Now Install Geant
- Decide on an install environment, and establish the environment variables. The example for the bash shell follows for CHLEP. You can put these commands into a file called "geant.sh Δ".
export CLHEP_DIR=/cygdrive/c/cygwin/usr/local export PATH="$PATH:$CLHEP_DIR/bin"
- Install and build CLHEP as per the instructions at (http://www.cern.ch/clhep).
- The environment example for geant4 is
- Geant wants to know where is CLHEP
export CLHEP_BASE_DIR=$CLHEP_DIR export CLHEP_INCLUDE_DIR=$CLHEP_DIR/include export CLHEP_LIB_DIR=$CLHEP_DIR/lib export CLHEP_LIB=CLHEP
- Geant wants to know where is the root build directory
export G4INSTALL=/cygdrive/c/geant4.7.1 export G4INCLUDE=$G4INSTALL/include export G4LIB=$G4INSTALL/lib
- Now select your system don't use compiler of MSVC++
- Simply go for a straight linux environment
export G4SYSTEM=WIN32-g++
- Now choose where you will put the executables and put them in the path
export G4WORKDIR="$HOME/My Documents/geant4" export G4TMP=$G4INSTALL/tmp export PATH="$PATH:$G4WORKDIR/bin/$G4SYSTEM"
- Now select various options ->
export G4LIB_BUILD_STATIC=1 #export G4LIB_USE_GRANULAR=1 export G4DEBUG=1
- to use the debugger or not
export G4OPTIMISE=' '
- We will use ROOT to analyse not JAG or AIDA
export G4ANALYSIS_USE=0 export G4UI_USE_ROOT=1 #export G4UI_USE_TCSH=1 export G4UI_USE_TERMINAL=1 export G4UI_USE_GAG=1 export G4UI_USE_XAW=1 export G4UI_USE_WO=1 #export G4VIS_USE_OIX=0 #export G4VIS_USE_DAWN=1 #export G4VIS_USE_VRML=1
- This prepares for Open GL build
export OGLHOME=/usr/X11R6 export G4VIS_BUILD_OPENGLX_DRIVER=1
- Choose non-permanent graphics window, low memory option
export G4VIS_USE_OPENGLX=1 #export G4VIS_USE_OPENGLXM=1
- Start a new X-shell and make sure your environment variables come through (use shell scripts to automate their setting). Build geant4 (after reading about installation procedures at http://geant4.cern.ch/ just by saying (in the geant source directory)
make
- Then test, by going to the novice N03 example tree and saying
make
- You can add a new visualisation manager by the following minimal rebuild of the visualisation system
touch $G4INSTALL/source/visualization/management/src/G4VisManager.cc cd $G4INSTALL/source/visualization/OpenGL; make clean cd $G4INSTALL/source/interfaces; make clean cd $G4INSTALL/source/; make
- Rebuild the your application as follows:
cd /path/to/example gmake clean gmake
- For example, from the GEANT4 www-page, you can follow the link to the Installation Introduction, and from there to the Dawn pages, and get Dawn working as well.