c++ - WSL Ubuntu 20.04.3 错误 : XDG_RUNTIME_DIR not set in the environment

标签 c++ windows ubuntu windows-subsystem-for-linux sdl-2

我在 Windows 10 上使用 Ubuntu 20.04.3 WSL。我将我的 C++ 程序(使用 SDL2 库)编译为名为“main”的可执行文件。

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

当我尝试使用以下命令运行可执行文件时:

./main

它返回:

error: XDG_RUNTIME_DIR not set in the environment.

最佳答案

感谢您的评论。答案已经在这里得到解答:QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-aadithyasb'

至于为什么可执行文件无法在 WSL 中运行,原因是 WSL2(截至 2021 年 12 月)尚未支持 GUI 应用程序。它仅适用于 Windows 11 Insider。这是链接:

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.

关于c++ - WSL Ubuntu 20.04.3 错误 : XDG_RUNTIME_DIR not set in the environment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70469462/

相关文章:

bash - 在 bash 脚本文件中终止具有多个条件的 while 循环

Android Wear 模拟器无法在 Ubuntu 14.04 上运行

c++ - 这些大小对于变量数组和变量指针数组是否正确?

c++ - 检测最终类别的特征

python - 使用pywinauto点击对话框取消按钮

windows - Windows 上 Ubuntu 上的 Bash 在 Windows 中的 Lxss 文件夹丢失

c - GLFW 窗口无法打开(Ubuntu)

c++ - 在 C++ 中的 vector 中的每个索引处查找累积唯一元素计数的有效方法

c++ - 带有模板函数的未解析外部符号

c - 我可以 #include 定义 DWORD 的最小 Windows header 是什么?