Can't Run GTK on WSL, Display Error

I'm using WSL on Windows 10. I've installed gtkwave through the terminal, but I am unable to run it. My system gives me the following error:

Could not initialize GTK! Is DISPLAY env var/xhost set?

I've tried installing xhost, but running xhost +LOCAL: only gives this error:

xhost: unable to open display ":0"

How can I fix this and run GTK GUIs?

1 Answer

WSL doesn't come with an X server by default, because Windows doesn't use an X server. Which would also be why xhost failed to do anything remotely useful.

In order to do something like this, you need to download an X server for Windows, and then configure that. For example, you can use the Xming project to run a display server. When launching Xming, you can use the -multiwindow option to make it so you don't have a virtual desktop. However, this may not be the case with other X servers present on Windows.

You can find a quick tutorial here for Xming specifically (really, it's just install + configure + export DISPLAY=:0) or here also for Xming. Alternatively you can use MobaXTerm (tutorial), which will achieve the same basic result.

In short, find an X server you like, and install it on Windows. After that, your WSL instance should be able to pick up on the fact that an X server is available, and you should be able to run GUI-based programs without much hassle.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like