1

I use Ubuntu 20.04.3 WSL on Windows 10. I compiled my c++ program (which uses the SDL2 library) into an executable file named "main".

g++ -o main main.cpp CApp.cpp -lSDL2 -std=c++17

When I try to run the executable with the following command:

./main

it returned:

error: XDG_RUNTIME_DIR not set in the environment.
Bountyhat
  • 141
  • 1
  • 1
  • 11
  • Related: [https://askubuntu.com/questions/872792/what-is-xdg-runtime-dir](https://askubuntu.com/questions/872792/what-is-xdg-runtime-dir) – drescherjm Dec 24 '21 at 04:13
  • Also: [https://stackoverflow.com/questions/59790350/qstandardpaths-xdg-runtime-dir-not-set-defaulting-to-tmp-runtime-aadithyasb](https://stackoverflow.com/questions/59790350/qstandardpaths-xdg-runtime-dir-not-set-defaulting-to-tmp-runtime-aadithyasb) – drescherjm Dec 24 '21 at 04:15
  • The error does not prompt now. But when I run the executable ./main, nothing happens? – Bountyhat Dec 24 '21 at 04:29

2 Answers2

5

Thanks for the comments. The answer is already answered here: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-aadithyasb'

As for why the executable cannot be run in WSL, the reason is because WSL2 (as of December 2021) has not yet supported GUI app. It is only available on Windows 11 Insider. Here is the link:

https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps

You will need to be on Windows 11 Build 22000 or higher to access this feature.

Bountyhat
  • 141
  • 1
  • 1
  • 11
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 24 '21 at 13:14
  • I have used [https://mobaxterm.mobatek.net/](https://mobaxterm.mobatek.net/) to run GUI applications in WSL in the past. These were binary applications from ubuntu and not my own applications and not built from source so I was not trying to use VSCode or Visual Studio Community – drescherjm Dec 24 '21 at 13:42
  • Certain GUI applications can absolutely work on WSL2, though I had some issues with it not updating vpn connectivity and was having to use X11 forwarding so when i would get on the VPN my session to X11 would get killed – linuxgeek Jun 16 '23 at 13:22
0

You can use software like xming on windows to launch an X server that wsl can launch GUI applications on. Though WSL1/2 may struggle if things need to access features like framebuffer as the kernels don't have support for that, i think most things using qt will fail too.

xming + xfce4-terminal + xcalc

linuxgeek
  • 57
  • 8