Skip to content

Install EGSnrc on Windows with WSL

Frederic Tessier edited this page Jan 23, 2019 · 1 revision

Overview (In progress...)

EGSnrc can be installed in its native GNU/Linux environment via the Windows Subsystem for Linux (WSL) on Windows 10 or Windows Server 1709 and later. WSL lets developers run a native Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a virtual machine.

WSL requires fewer resources (CPU, memory, and storage) than a full virtual machine. WSL also allows you to run Linux command-line tools and apps alongside your Windows command-line, desktop and store apps, and to access your Windows files from within Linux. This enables you to use Windows apps and Linux command-line tools on the same set of files if you wish.

This EGSnrc installation method affords many advantages:

  • quickly install EGSnrc in a fail-safe way
  • dodge installation issues on macOS or Windows
  • enjoy a consistent EGSnrc experience across different computing platforms
  • shelter your working copy against changes in the host OS
  • install on a system with limited administration rights
  • practice before installing on your main Linux system

The following instructions will guide you through the required steps to get EGSnrc running on WSL.

Installing EGSnrc in a WSL Linux system involves 3 steps:

  1. Enable WSL
  2. Install an available Linux distribution
  3. Install EGSnrc

Apart from the time required to download files, the entire installation process takes about 20 minutes on a modern computer.

1. Enable WSL

Before you can run Linux distros on Windows, you must enable the "Windows Subsystem for Linux" optional feature for Windows 10 or Windows Server and reboot when prompted. This reboot is required in order to ensure that WSL can initiate a trusted execution environment.

2. Install an available Linux distribution

Follow the specific installation instructions for Windows 10 or Windows Server.

5. Install EGSnrc

At this point you have a basic Linux system, and you can follow the instructions to Install EGSnrc on Linux as usual. For completeness we provide below detailed step for quick installation on an Ubuntu base system.

  1. Open a terminal (Ctrl+Alt+T) and issue the following commands to install the pre-requisite software, and some optional ones:

    sudo apt -y install git gcc gfortran make tk expect
    sudo apt -y install libmotif-dev qt5-default 
    sudo apt -y install imagej kate
    
  2. Clone the EGSnrc repository and checkout the develop branch, with the following commands:

    git clone https://github.com/nrc-cnrc/EGSnrc.git
    cd EGSnrc
    git checkout develop
    
  3. Configure EGSnrc on your machine, using the default options, with the command:

    HEN_HOUSE/scripts/configure.expect linux.conf 1
    

    For a faster installation, you can skip the compilation of all EGSnrc applications by entering a 3 instead of 1 in the command above, and compile any individual application you want to use later on by going to the application directory and issuing the make command. If you want to enter different configuration options interactively, run HEN_HOUSE/scripts/configure instead.

  4. Important: edit the text file .bashrc in your home directory to add the 3 configuration text lines specified at the end of the configuration script (for editing you can use Application menu > Accessories > FeatherPad, or Kate):

    export EGS_HOME=~/EGSnrc/egs_home/
    export EGS_CONFIG=~/HEN_HOUSE/specs/linux.conf
    source ~/EGSnrc/HEN_HOUSE/scripts/egsnrc_bashrc_additions
    

    Close the terminal window, and open a new one (Ctrl+Alt+T) to ensure that the definitions above are loaded. You can verify that is the case with echo $EGS_HOME, which should return the string /home/yourname/EGSnrc/egs_home/ (where yourname is your chosen login name).

  5. Compile the EGSnrc gui applications: issue the following commands in the terminal (takes a while, and don't worry about compiler warnings):

    export QTDIR=/usr/lib/qt5 (Lubuntu)
    export QTDIR=/usr/lib/x86_64-linux-gnu/qt5/ (Ubuntu)
    cd ~/EGSnrc/HEN_HOUSE/gui/ && make --quiet --print-directory
    cd ~/EGSnrc/HEN_HOUSE/egs++/view/ && make --quiet --print-directory
    cd ~/EGSnrc
    
  6. To run GUIs from bash

  • Install an X server (XMing or VcXsrv)

  • Set environment variable DISPLAY temporarily by issuing the command

    export DISPLAY=:0

    or add the above line to your .bashrc file for a permanent definition

  1. To access same EGSnrc repository on Windows and Linux

    Create symbolic link `/home/your_user_name/EGSnrc -> /mnt/c/users/your_user_name/EGSnrc`
    
  2. Run a sample egs_app simulation of a 20 MeV electron pencil beam impinging on a 1 cm thick water slab, and display the geometry and some particle tracks with the egs_view utility:

    cd ~/EGSnrc/egs_home/egs_app
    make
    egs_app -i slab.egsinp
    egs_view slab.egsinp slab.ptracks
    

Congratulations, you are done, enjoy your fresh EGSnrc installation!

Clone this wiki locally