0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

WSL2 + vcXsrvでGUI(Windows11)

Last updated at Posted at 2025-08-25

Windows10でWSL2にてvcXsrvを用いてGUIを動かしていましたが、Windows11にアップグレードしたところ動かなくなりました。Windows11ではWSLgでGUIをネイティブサポートしているようですが、再インストールが面倒なことから代替案を見つけました。備忘録もかねて導入手順を紹介します。

GUI導入手順

  • WindowsにVcXsrvをインストールする

  • XLaunchを起動し初期設定する

    • スタート画面より「XLaunch」を起動

    • 「Select display settings」で「Multiple windows」を選択し、「Display number」は0とする

    • Select how to start clientsはStart no clientに✓

    • Extra settingsはClipboard>Primary SelectionとNative openglに✓を入れ、Additional parameters for VcXsrvに「-ac -nowgl」と指定

    • Save configuration をクリックし、スタートアップフォルダに設定ファイルを保存する

      スタートアップフォルダはWin+rでshell:startupとすると開ける

    • タスクバーにXのアイコンが表示され、カーソルをかざすと「PC名:0.0」と表示されていれば完了

  • Linux側にXorgをインストールする

    • sudo dnf install Xorg
  • Linux側でディスプレイ設定をする

    • ip routeでIPアドレスを取得する:ここがWindows11で変わった点になります
      export DISPLAY=$(ip route | awk '/default/ {print $3}'):0
      
      ちなみに以前は、
      ~/.cshrc
      export DISPLAY=`cat /etc/resolv.conf | grep nameserver | awk '{print $2;}'`:0.0 # 0.0はXのアイコンの「PC名:」の後の数字
      
      としていました。
      この値は毎回変わるので、.bashrcに設定する。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?