# WSL2

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/ja-jp/help/clion/llms.txt).

> **TL;DR**
> ローカルクライアント OS  : Windows
>
>
>
> リモートホスト OS  : WSL [Linux ディストリビューション](https://jb.gg/clion-wsl)
>
>
>
> ソースの場所  : ローカルマシン
>
>
>
> プロジェクトモデル  : [CMake](quick-cmake-tutorial.html) / [Makefile](makefiles-support.html) / [コンパイルデータベース](compilation-database.html)

> **Warning:**
> Gradle または Maven プロジェクトを操作するには、   リモート実行エージェント：バイナリファイル  が [有効化](managing-plugins.html)されていることを確認してください。

[WSL](https://docs.microsoft.com/en-us/windows/wsl/about) ( [WSL 2](https://docs.microsoft.com/en-us/windows/wsl/wsl2-index)) – Windows Subsystem for Linux – は、Windows 10 以降で Linux バイナリ実行ファイルをネイティブに実行するための互換性レイヤーです。 現在、Ubuntu、OpenSUSE、SLES など、いくつかの [Linux ディストリビューション(英語)](https://docs.microsoft.com/windows/wsl/install-win10#windows-10-fall-creators-update-and-later-install-from-the-microsoft-store)をサポートしています。

With  WSL toolchain  set up for your project, you can build using a toolchain from Linux, and run/debug on WSL, without leaving CLion running on your Windows machine.

> **Note:**
> You don't need to install or run CLion inside WSL.

Procedure: WSL を設定する

1. Windows マシンで [Microsoft Store](https://jb.gg/clion-wsl) から WSL ディストリビューション（例えば Ubuntu）をダウンロードしてインストールします。

この手順では、最新の「Fall Creators Update」(最小バージョン 1709、ビルド 16299.15) を適用した少なくとも Windows 10 以降を使用してください。 手順については、公式ガイド [Linux 用の Windows サブシステムをインストールする](https://docs.microsoft.com/en-us/windows/wsl/install-win10)を参照してください。

WSL 2​   を使用するには、Windows のバージョンが 10 ビルド 18917 以降である必要があります。 [これらの手順(英語)](https://docs.microsoft.com/windows/wsl/wsl2-install#set-a-distro-to-be-backed-by-wsl-2-using-the-command-line)に従って、ディストリビューションを切り替えます。

Note that CLion does not support   既存 WSL​  , which you may have installed before upgrading your system to the build 16299.15 or later of Windows 10. この場合、WSL ディストリビューションを更新する必要があります。

2. Linux ディストリビューションを実行します。

最初の起動時に、システムは Windows のオプション機能を有効にするように求めるメッセージを表示する場合があります。 この場合、次のことを行う必要があります。

* 管理者として Windows PowerShell を開き、実行します ```SHELL Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux ```

* コンピューターを再起動してください。

> **Note:**
> Ubuntu 以外の Linux ディストリビューションを使用している場合は、ディストリビューションに [iproute2(英語)](https://wiki.linuxfoundation.org/networking/iproute2) パッケージがインストールされていることを確認するか、WSL インスタンスがデプロイされたら手動でインストールします。

3. Linux ディストリビューション環境をセットアップします。

次のように、cmake、gcc、clang（およびオプションで  build-essentials  パッケージ）をインストールします。

```CONSOLE
sudo apt-get update
sudo apt-get install cmake gcc clang gdb build-essential

```

Procedure: プロジェクト用に WSL ツールチェーンを設定する

1. CLion で  `設定 | ビルド、実行、デプロイ | ツールチェーン`  に移動します。

2. ![plus icon](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg) をクリックして新しいツールチェーンを作成し、   WSL   を選択します。

3. ツールセット   フィールドで、利用可能な WSL ディストリビューションのいずれかを選択します。 リストには、インポートされたものを含め、  `wsl.exe --list`  によって検出されたディストリビューションが含まれます。

> **Note:**
> If CLion cannot find your WSL executable, the reason might be the [WSL issue](https://github.com/Microsoft/WSL/issues/2592) fixed in   Windows10 バージョン 1803  . システムをバージョン 1803 以降に更新してみてください。

![WSL ツールチェーン](https://resources.jetbrains.com/help/img/idea/2026.3/cl_wsl_new_toolchain.png)

すべてのツールが検出されるのを待ち、設定を保存します。

> **Tip:**
> You can configure CLion to execute WSL commands in login (-l) shell. 詳細については、 [このページ](advanced-settings.html#advanced-wsl)を参照してください。

4. ツールチェーンの使用を開始するには、次の手順を実行します。

CMake:

1.  WSL ツールチェーンを   デフォルト   として設定する (リストの一番上に移動する) か、 [関連付けられた CMake プロファイルを作成します](remote-projects-support.html#CMakeProfile)。

2.  [Build](build-actions.html), [run](running-applications.html), and [debug](debugging-code.html) as usual.

> **Tip:**
> WSL で   Valgrind​   を実行するには、WSL ツールチェーンに関連付けられた CMake プロファイルを必ず選択してください。 詳細については、 [この説明](memory-profiling-with-valgrind.html#valgrind-wsl)を参照してください。

Makefile:

1.   `設定 | ビルド、実行、デプロイ | Makefile`  で WSL ツールチェーンに切り替えます。

2.   `ツール | Makefile | Makefile プロジェクトのクリーンと再ロード`  を呼び出します。

3.  In the [Native Application](makefiles-support.html#create-makefile-config) configuration, point   実行可能ファイル   to the binary using the  `\mnt\..`  notation (for example,  `\mnt\c\Users\jetbrains\CLionProjects\SimpleMakefile\runme` ).

> **Note:**
> [Makefile プロジェクトを操作するときの WSL の仕様](makefiles-support.html#wsl-notes)を参照してください。

## See also

### ハウツー

[Remote development overview](remote-development.html)

### オンラインドキュメント

[Quick Tutorial: Configuring CLion on Windows](quick-tutorial-on-configuring-clion-on-windows.html)

### 外部リンク

[CLion Debugging Beyond the Basics - Part 3 - Beyond Local](https://blog.jetbrains.com/clion/2021/05/clion-debugging-beyond-the-basics-part-3-beyond-local) [Webinar Recording: Remote Development with CLion](https://blog.jetbrains.com/clion/2019/03/webinar-recording-remote-development-with-clion)

