Skip to content

Development Environment

This article describes how to set up various development environments and tools for working with computational physics. This page is actively maintained as of Jun 8, 2021. The instructions will be updated as needed, if you run into any issues, please let me know.

Windows Subsystem For Linux 2

Windows has built-in software to allow running of Linux operating systems within windows. This may be preferable over a full install for learning and experimenting with Linux. Commands are to be executed in Powershell as Administrator, you must be running Windows 10 Version 1903 or higher and virtualization must be enabled

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Restart your computer (actually click restart, shutting down will not work).

Invoke-WebRequest -Uri "https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi" -Outfile ~\Downloads\wsl_update_x64.msi
~\Downloads\wsl_update_x64.msi

Follow onscreen instructions to install the WSL kernel.

wsl --set-default-version 2

Open the Microsoft Store and install your preferred Linux Distribution (Ubuntu and Debian are the best supported in WSL). If you would like to run graphical applications, you will need an X server. Install VcXsrv to the default path, then run

& 'C:\Program Files\VcXsrv\xlaunch.exe'

Use the default settings for the first two pages. On the third page, uncheck Native opengl and check Disable access Control. In your Linux subsystem, create an environment variable to allow programs to use the X server. Allow WSL to communicate with Windows by running

Set-NetFirewallProfile -DisabledInterfaceAliases "vEthernet (WSL)"

Start linux, set your username and password, then run

echo 'export DISPLAY=$(awk '"'"'/nameserver / {print $2; exit}'"'"' /etc/resolv.conf 2>/dev/null):0\nexport LIBGL_ALWAYS_INDIRECT=1' >> ~/.bashrc
. ~/.bashrc

C/C++ Compilers and Build tools

Arch Linux

sudo pacman -Syu base-devel

Ubuntu

sudo apt update
sudo apt install build-essential manpages-dev

MacOS
Head to Apple Developer Downloads, download and install the latest (non-beta) "Command Line Tools for Xcode".

CERN Root Data Analysis Framework

Arch Linux

sudo pacman -Syu root

Ubuntu (WSL 2)
Snap currently does not support Windows Subsystem for Linux 2. You will need to install root manually.

sudo add-apt-repository ppa:rock-core/qt4
sudo apt-get update
sudo apt-get install dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev python libssl-dev gfortran libpcre3-dev xlibmesa-glu-dev libglew1.5-dev libftgl-dev libmysqlclient-dev libfftw3-dev libcfitsio-dev graphviz-dev libavahi-compat-libdnssd-dev libldap2-dev python-dev libxml2-dev libkrb5-dev libgsl0-dev libqt4-dev
cd ~
wget https://root.cern/download/root_v6.24.00.Linux-ubuntu20-x86_64-gcc9.3.tar.gz
tar -xzvf root_v6.24.00.Linux-ubuntu20-x86_64-gcc9.3.tar.gz
echo 'source root/bin/thisroot.sh' >> ~/.bashrc
. ~/.bashrc

Ubuntu (Native)

sudo snap install root-framework

If you would like to run root without sandboxing from snap, then

snap run root-framework

MacOS
Head to Apple Developer Downloads, download and install the latest (non-beta) "Command Line Tools for Xcode". You do not need to install the Xcode app. You may need to disable your antivirus temporarily during installation.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install root

Vivado

It is recommended that you install all major versions if you have space on your disk. Red Pitaya is currently being developed on Vivado 2019.2 if you only have space for a single Viviado version.

Arch Linux
Make sure your system locale is set to en_US.UTF-8.

git clone https://aur.archlinux.org/vivado.git
cd vivado
makepkg -si
mkdir -p ~/.local/bin
echo '#!/bin/sh\nuname -m' > ~/.local/bin/arch

For Vitis_HLS 2020.2, a patch is needed to fix a bug that prevents it from running. Find Vitis_HLS/2020.2/common/scripts/autopilot_init.tcl and edit line 40 from ----%r&-'%rl%&n$&lt'v-= to ----%r&-'%rl%&n$&lt'v->.

Ubuntu / Windows
Download Xilinx Unified/Web Installer and follow the on-screen instructions to install Vivado, Vitis, as well as support packages for the boards you intend to work on (you can change this later if you're unsure).

Text Editors

Here's a list of popular text editors and a brief description. You should use your distro's package manager to install these

  • Visual Studio Code - Feature rich text editor with syntax highlighting and linting for nearly every type of file through extensions.
  • Vim - Ancient text editor that you will spend 2 minutes trying to exit your first time using it.
  • Neovim - Vim but actually usable.
  • Emacs - Imagine like, keyboard shortcuts, but in Einstein notation.

Arch Linux

Arch is a Linux distribution focused on user controlled maintainence and system configuration. If you are not interested in configuring your own Linux system, other distros such as Ubuntu, Debian, and Fedora are configured by their respective parent companies. This is a supplement to the Official Installation Guide making recommendations for decisions you need to make when following the guide. The first major decision will be partitioning the disks. Two partitions are needed

  • EFI System Partition (ESP - Recommended Size = 498MB): This partition contains a simple filesystem that is widely supported by most devices. We typically want a more complex filesystem for the Linux system, however these are rarely supported by most devices' firmware. Hence, a seperate partition, the ESP, is used to store applications and drivers that allow us to read and boot the Linux system.
  • Linux System Partition (root - Recommended Size >= 100GB): This partition contains most or all of the files for the operating system. Some of the tools we will use such as Vivado and CERN Root will take a considerable amount of space, hence at least 100GB is recommended.

Next, you will need to create a filesystem on each partition. Below are my recommendations for the filesystems and a brief explaination. You can look through Wikipedia if you would like a comparison of filesystems.

  • ESP: FAT32 - Universally supported, allows the system to boot from basically any system capable of loading an EFI, uboot, or coreboot. The ESP filesystem should be mounted at /boot if you would like all files required for booting to be stored in the ESP.
  • root: BTRFS - A stable filesystem with checksumming to ensure silent corruption is impossible. It also supports snapshotting and other backup features which is important for a development environment. Supports transparent filesystem compression and encryption.

In order to boot the system, you have a few options.

  • rEFInd (Recommended): A user-friendly boot menu that has an automated install process and requires no additional configuration. rEFInd will automatically detect operating systems available to your system, and handle creating the appropriate paramaters for loading these systems.
  • Grub: A feature-rich bootloader that supports encryption, btrfs snapshot recovery, among other features. However, grub does not auto-detect operating systems at boot time, nor is it able to automatically create parameters to boot. These will need to be configured using a script grub-mkconfig each time you change your system configuration.
  • UEFI Loader (Not Recommended): If you're using a computer built in the last couple of decades, chances are your system will have a built-in bootloader in an UEFI. This can be configured using efibootmgr to directly load a Linux operating system from the vmlinuz image.

Follow the official installation guide and associated subpages for decisions on other system components, such as desktop environments, shells, etc... These are mostly up to your preference.

Linux on T2 Macbooks (2018 and Newer)

If you would like to run Linux natively on Macbooks, you will need

And optionally

Guides are currently available on T2Linux. I will write a guide that doesn't require any external connections or dongles soon.