Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Making SFML work with WSL2  (Read 7802 times)

0 Members and 1 Guest are viewing this topic.

jokoon

  • Newbie
  • *
  • Posts: 35
    • View Profile
Making SFML work with WSL2
« on: November 13, 2021, 12:59:04 pm »
WSL2 now supports gui applications!

Since I was quite annoyed by visual studio, I decided to use WSL2 and make as a dev environnement. I've read it works on win10 not only win11.

Installing WSL is pretty straightforward, I'll let you do it. I reinstalled my WSL image and added the WSL kernel update provided by microsoft.

sudo apt install libsfml-dev
works.


My make script builds fine.

I'm now getting:

Failed to open X11 display; make sure the DISPLAY environment variable is set correctly
Aborted

I tried
export DISPLAY=:0
and other things, I installed vcxsrv.exe, and I still get the error.

Then you must do

export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
export LIBGL_ALWAYS_INDIRECT=0

In your WSL terminal.

Then run xlaunch.exe and tick the right boxes like in the linked image.



It works!
« Last Edit: November 13, 2021, 01:54:08 pm by jokoon »