have any of you tried compile and executing SFML c++ project output on wsl?
I tried and got
Failed to open X11 display; make sure the DISPLAY environment variable is set correctly
Aborted
Is it possible at all to execute GUI applications through wsl?
(I’ve installed ubuntu’s for wsl)
2
Answers
If you had the same problem
first, you need to install VcXsrv and X11 for executing GUI applications through wsl
then you have to add these 2 to your environment variables:
export DISPLAY=:0
export LIBGL_ALWAYS_INDIRECT=0
Linux distributions set up for WSL 1 will not function with Linux GUI applications, which are only supported with WSL 2.
Due to the official documentation from Microsoft regarding WSL, you might need to check these steps:
Select Start, type PowerShell, right-click Windows PowerShell, and then select Run as administrator.
after that type this command and then press enter:
You will need to restart WSL for the update to take effect. You can restart WSL by running the shutdown command in PowerShell.
now, once again open powershell and type in this command:
You should see the number
2
for your installed distro under the headingVERSION
in the response.If everything went as planned until this point, see if your distro can open any windows by installing a GUI app like gedit and trying to open it:
now install gedit:
After the installation has finished, launch gedit by typing
gedit
in your wsl terminal. A window from wsl inside of Windows should now open, and the issue should now be resolved.find more information here:
https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps