Quantcast
Channel: Active questions tagged windows-subsystem-for-linux - Ask Ubuntu
Viewing all articles
Browse latest Browse all 2798

Setting up the $DISPLAY environment variable on WSL2 to use Qt software

$
0
0

I am working on WSL2 (Ubuntu 20.04) and I have trouble setting up the $DISPLAY environment variable. More specificallly, I have a network configuration that allows me to ping devices connected to eth0, but I cannot run Qt apps.

When I run Qt software like Wireshark or in-house software from my company, I have this error message:

user@DESKTOP-XXX:~$ wiresharkqt.qpa.xcb : could not connect to display 0qt.qpa.plugin: Couoldl not load the Qt platform plulgin "xcb" in "" even though it was found.

Looking this up, I understood that my $DISPLAY variable is not set properly. (I checked and the "xcb" plugin is installed and Qt locates it). I am now on a quest to understand the $DISPLAY envionment variable, and more specifically, how it works on WSL2. I found this great AskUbuntu answer about generalilties, but since WSL2 works a bit particularly (virtual machine, Hyper-V Virtual switch, etc), I can't understand what to set $DISPLAY to to communicate with something connected via Ethernet.

My network settings for WSL2:

I want to cmmunicate with a machine connected via Ethernet on my WSL2 computer. To do this, I set up the following configuration, that allows me to ping the machine:

  • Hyper-V virtual manager Windows app: WSL virtual switch set up as "External network" via the Ethernet connector I use
  • Network Connections Windows app:
    • Ethernet:
      • "Hyper-V extensible virtual switch" checked
    • vEthernet (WLS):
      • Hyper-V extenible virtual switch unchecked;
      • IPV4: IP 10.0.0.10, gateway 10.0.0.3, favorite DNS 0.0.0.0
  • Ubuntu network settings:
    • sudo ifconfig eth0 10.0.0.3 netmask 255.255.255.0
    • sudo ip route add default via 10.0.0.5 dev eth0

This setup allows me to ping my external machine via 10.0.0.2. (If I want to reach Internet via eth0, I need to add nameservers to resolv.conf.)

However, Qt apps still cannot reach it. And they cannot run at all. When I launch, for instance, Wireshark, I have the error message I stated above.

Some solutions I tried, inspired by things I found online:

user@DESKTOP-XXX:~$ export DISPLAY=0.0qt.qpa.xcb : could not connect to display 0.0user@DESKTOP-XXX:~$ export DISPLAY=8080qt.qpa.xcb : could not connect to display 8080user@DESKTOP-XXX:~$ export DISPLAY=10.0.0.2qt.qpa.xcb : could not connect to display 10.0.0.2user@DESKTOP-XXX:~$ export DISPLAY=10.0.0.2:0# infinite loading

Viewing all articles
Browse latest Browse all 2798

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>