Based on this guide: https://medium.com/@japheth.yates/the-complete-wsl2-gui-setup-2582828f4577
-
Enable WSL2 features
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
-
Update WSL and set default version for
ubuntu
(replace with your distro, ifwsl --list
shows different name)wsl --status wsl --list wsl --update wsl --shutdown wsl --set-default-version wsl --set-version ubuntu 2
Download VcXsrv
Start it by searching for XLaunch
and use options:
- Multiple windows
- uncheck [ ] Naive Opengl
- check [x] Disable auth
-
xorg graphical user interface base system
sudo apt install xorg
-
xorg dev libraries
sudo apt install libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
-
opengl dev libraries
sudo apt install freeglut3 freeglut3-dev libglu1-mesa libglu1-mesa-dev libgl1-mesa-glx libgl1-mesa-dev
Add the following lines to the end of ~/.bashrc
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0
export LIBGL_ALWAYS_INDIRECT=0
sudo /etc/init.d/dbus start &> /dev/null
Restart WSL by closing all wsl clients, running wsl --shutdown
and starting it again.
In WSL console, run xeyes