seigot/tetris

window wsl環境で実行を試みたものの起動しない(`qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.`)

Opened this issue · 2 comments

windows11であれば以下で解決する可能性あり

windows11であれば、最新のwsl2を使用することで、wsl2で起動したGUIアプリを勝手にwindowsのデスクトップに表示してくれます。(テトリスの画面が出るようになります)
なので、やることとしては以下になります。
・wsl1なのかwsl2なのか確認https://docs.microsoft.com/ja-jp/windows/wsl/install#upgrade-version-from-wsl-1-to-wsl-2
・wsl2であれば最新版にする(wsl --update、pc再起動した方がいいかもです)

https://qiita.com/yugo-yamamoto/items/28e3d2a090f8f546f3ec が参考になります。
sudo apt install x11-apps後にxeyesを打って目の絵が出てくれば成功です。

The issue you're experiencing with the Qt platform plugin "xcb" on WSL1 is due to limited GUI support and missing dependencies in WSL1. Here are the steps to resolve this:

  1. Upgrade to WSL2: WSL2 provides better support for GUI applications. You can upgrade by running:

    wsl --update
    wsl --set-version <distribution_name> 2

    For detailed instructions, refer to Microsoft's official documentation.

  2. Install Required Qt Dependencies: In WSL2, run the following commands to install necessary packages:

    sudo apt-get update
    sudo apt-get install -y libxcb-xinerama0
  3. Set DISPLAY Environment Variable and Start X Server:

    • Start an X server on Windows (e.g., VcXsrv or GWSL).
    • Set the DISPLAY environment variable in WSL2 by adding the following to your ~/.bashrc:
      echo 'export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0.0' >> ~/.bashrc
      source ~/.bashrc
  4. Update Documentation: Add these steps to doc/files/install_windows_wsl.md to guide users through the setup process.

These steps should help resolve the issue by ensuring the necessary environment and dependencies are in place for running Qt applications on WSL.