# Tutorial: Configure CLion on Windows

On Windows, CLion toolchains include the build tool, C and C++ compilers, debugger executable, and the environment. You can select one of the pre-defined toolchain setups ([MinGW](#MinGW), [Cygwin](#Cygwin), [Microsoft Visual C++](#MSVC), or [WSL](#WSL), [Remote Host](remote-projects-support.html#remote-toolchain), [Docker](clion-toolchains-in-docker.html)) or configure a custom toolchain ([System](#system)):

![Windows toolchain options](https://resources.jetbrains.com/help/img/idea/2026.2/cl_toolchain_options.png)

Watch this video for an overview of Windows toolchain options:

[Video](https://www.youtube.com/v/Vj06cfj6LyI)

> **Tip:**
> If you don't need to configure custom tools or don't want to install additional software on your system, stick to [MinGW](#MinGW) (default) as it works out-of-the-box using the MinGW toolset bundled in CLion.

For more information about Remote Host toolchains, refer to [Remote with local sources](remote-projects-support.html#remote-toolchain). If you are working with a Docker container, refer to [Docker toolchain](clion-toolchains-in-docker.html).

## MinGW

CLion bundles a version of the MinGW toolset for quick setup. The exact version bundled is MinGW-w64 13.1 with `languages=c,c++`, `posix` threads, and `seh` exceptions. You can use this bundled toolchain or switch to a custom MinGW installation.

### Install MinGW (optional)

MinGW-w64 (64- and 32-bit):

Procedure:

1. Download and run the [MinGW-w64](https://jb.gg/clion-mingw) installer. It provides both 64- and 32-bit options.

2. In the MinGW-w64 installation wizard, make sure to select the required architecture. Note that the default suggested option is 32-bit.

![Selecting the 64-bit architecture for MinGW](https://resources.jetbrains.com/help/img/idea/2026.2/cl_mingw_64_arch.png)

3. Wait for installation to finish.

MinGW (32-bit only):

Although MinGW-w64 provides both 64- and 32-bit options, you can also install [MinGW](https://osdn.net/projects/mingw/), the 32-bit-only version.

Procedure:

1. In the MinGW installation wizard, select the following packages from the Basic Setup list: `mingw-developer-tool`, `mingw32-base`, `mingw32-gcc-g++`, `mingw32-msys-base`.

![MinGW installation](https://resources.jetbrains.com/help/img/idea/2026.2/cl_MinGWInstall.png)

2. Wait for installation to finish.

Procedure: Configure a MinGW toolchain

1. Go to `File | Settings | Build, Execution, Deployment | Toolchains`.

Click ![Add toolchain](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) and select MinGW to add a new MinGW toolchain.

2. In the Toolset field, you will see Bundled MinGW, which is the default option. If required, open the field to select from the list of other available installations:

![List of MinGW installations](https://resources.jetbrains.com/help/img/idea/2026.2/cl_mingw_bundled_list.png)

3. Wait until the tools detection finishes.

![Bundled MinGW toolchain](https://resources.jetbrains.com/help/img/idea/2026.2/cl_mingw_bundled_tools_detected.png)

4. Select the Debugger: you can use either bundled GDB, your MinGW GDB, or a custom GDB binary.

> **Note:**
> * Bundled GDB is recommended, since it is guaranteed to include Python support required for CLion [data renderers](configuring-debugger-options.html#debugger-renderers).
>
> * GDB does not yet support debugging on Windows ARM64. For this type of system, CLion's bundled GDB is intended to be used for remote debugging only.

5. If required, [specify the script to initialize the environment](how-to-create-toolchain-in-clion.html#env-scripts).

6. Click Apply when all the tools are set correctly.

> **Tip:**
> When using a custom MinGW installation, if CLion cannot detect the compilers, double-check the installed packages in MinGW Installation Manager.

## Cygwin

Procedure:

1. Download the [Cygwin](https://jb.gg/clion-cygwin) installer, version 2.8 or later.

2. Run the installer and select the following packages:

* `gcc-g++`

* `gdb`

To select a package, type its name in the Search field and set the version in the New column:

![Cygwin installation](https://resources.jetbrains.com/help/img/idea/2026.2/cl_CygwinSetup.png)

3. Once the installation is finished, open CLion and go to `File | Settings | Build, Execution, Deployment | Toolchains`.

4. Click ![Add toolchain](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) and select Cygwin to add a new Cygwin toolchain.

CLion will attempt to detect the Cygwin installation automatically. Check the Toolset field, and specify the path manually if required.

5. Wait until the tools detection finishes, and click Apply.

![Cygwin toolchain](https://resources.jetbrains.com/help/img/idea/2026.2/cl_cygwin_toolchain.png)

6. If required, [specify the script to initialize the environment](how-to-create-toolchain-in-clion.html#env-scripts).

## Windows Subsystem for Linux

You can use [WSL](https://docs.microsoft.com/en-us/windows/wsl/about), Windows Subsystem for Linux, as your working environment in CLion on Windows 10 (starting the Fall Creators Update version 1709, build 16299.15).

WSL toolchain enables you to build projects using CMake and compilers from Linux and run/debug on WSL without leavCLionLion running on your Windows machine.

> **Note:**
> For more information about setting up WSL on your system and configuring WSL toolchains, refer to [WSL guide](how-to-use-wsl-development-environment-in-product.html).

![WSL toolchain](https://resources.jetbrains.com/help/img/idea/2026.2/cl_wsl_new_toolchain.png)

## Microsoft Visual C++

Procedure:

1. Install [Visual Studio](https://jb.gg/clion-msvs) 2017, 2019, or 2022 on your system.

2. In CLion, go to `File | Settings | Build, Execution, Deployment | Toolchains`.

3. Click ![](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) and select Visual Studio from the list of toolchain templates.

4. Check the Toolset field. CLion will attempt to automatically detect the installed Visual Studio distribution. If the detection fails, set the path to Visual Studio manually.

5. If required, specify the Architecture (x86, amd64, x86_arm, or another), Platform (store, uwp, onecore, or leave it blank), and Version. To build your project for the selected architecture, CLion will call the script to configure the environment with the specified parameters.

> **Tip:**
> If the version of your compiler toolset is earlier than the version of your Visual Studio installation, pass it in the Version field via the `vcvars_ver` flag, for example, `-vcvars_ver=14.16`.

6. Wait until the tools are detected:

![MSVC toolchain](https://resources.jetbrains.com/help/img/idea/2026.2/cl_msvc_toolchain.png)

7. If required, [specify the script to initialize the environment](how-to-create-toolchain-in-clion.html#env-scripts).

### MSVC compiler

CLion supports the Microsoft Visual C++ compiler that ships with Visual Studio 2017, 2019, and 2022.

For the case when your code includes [MSVC extensions](https://docs.microsoft.com/cpp/build/reference/microsoft-extensions-to-c-and-cpp), CLion provides the support for:

* `__uuidof`, `__forceinline`, `__unaligned`, and `__alignof` keywords;

* pointer type attributes: `__ptr32`, `__ptr64`, `__uptr`, `__sptr`;

* MSVC built-in data types: `(unsigned) __int8`, `(unsigned) __int16`, `(unsigned) __int32`, `(unsigned) __int64`, `__wchar_t`;

* additional format specifiers, such as `%I32` and `%I64`;

* the [clang](https://clang.llvm.org/)'s `-fms-extensions` flag.

### Clang-cl compiler

As an alternative compiler, you can use [clang-cl](https://clang.llvm.org/docs/UsersManual.html#clang-cl) - the MSVC-compatible compiler driver for Clang. CLion supports clang-cl version 8.0 and later.

Procedure:

1. Install clang-cl from the [LLVM site](http://llvm.org/releases/download.html) or along with the Visual Studio tools.

When installed from the LLVM site, the clang-cl binary can be found at the standard location `C:\Program Files\LLVM\bin\clang-cl.exe` for the 64-bit version or `C:\Program Files (x86)\LLVM\bin\clang-cl.exe` for the 32-bit version.

2. In CLion, go to `File | Settings | Build, Execution, Deployment | Toolchains` and select the Visual Studio toolchain that you want to configure, or [create](#new-toolchain) a new one.

3. Point the C Compiler and C++ Compiler fields to `clang-cl.exe`. CLion will suggest the paths detected automatically.

![Clang-cl compiler](https://resources.jetbrains.com/help/img/idea/2026.2/cl_msvc_toolchain_clang.png)

Note that currently the `-T clangcl` options can't be picked up if the bundled CMake is in use along with the Visual Studio toolchain setup ([CPP-18848](https://youtrack.jetbrains.com/issue/CPP-18848)).

### MSVC debugger

The MSVC toolchain debugger is implemented on top of LLDB, and it can work with native visualizers from the Visual Studio installation or from your project.

Native visualizers, or Natvis renderers, enabled by default in CLion. To set the desired diagnostics level, go to `Settings | Build, Execution, Deployment | Debugger | Data Views | C/C++ | Renderers`:

![MSVC Natvis](https://resources.jetbrains.com/help/img/idea/2026.2/cl_msvc_natvis.png)

CLion automatically generates one-line summaries for all structures not covered by Natvis and highlights them to increase readability. Also, the built-in formatters provide visualization for wide/Unicode strings (`wchar_t`, `char16_t`, `char32_t`).

By default, CLion will automatically find and load `.natvis` files added to the project model, belonging to the selected MSBuild or MSVC toolchain, or located in `%USERPROFILE%\Documents\Visual Studio Version\Visualizers`.

![MSVC debug with custom NatVis](https://resources.jetbrains.com/help/img/idea/2026.2/cl_msvc_debug_natvis.png)

You can also specify a custom location for `.natvis` files. Go to `Settings | Build, Execution, Deployment | Debugger | Data Views | C/C++` and add an additional directory with Natvis renderers:

![Custom location for Natvis files](https://resources.jetbrains.com/help/img/idea/2026.2/cl_msvc_natvis_location.png)

CLion supports most of the Natvis customization features, such as [ArrayItems](https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects#BKMK_ArrayItems_expansion), [IndexListItems](https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects#BKMK_IndexListItems_expansion), [LinkedListItems](https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects#BKMK_LinkedListItems_expansion), [TreeItems](https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects#BKMK_TreeItems_expansion), [Inheritable attribute](https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects#inheritable-attribute), [Format specifiers](https://docs.microsoft.com/en-us/visualstudio/debugger/format-specifiers-in-cpp), and [CustomListItems](https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects#customlistitems-expansion).

When using the MSVC toolchain debugger, you can enable symbol servers support which will help the debugger resolve library symbols correctly. For more information, refer to [Use symbol servers when debugging on Windows](using-symbol-servers-when-debugging-on-windows.html).

## System toolchain

The System toolchain on Windows allows configuring the build tool, compilers, and debugger without selecting a predefined toolset or environment, similarly to Linux and macOS. Use this toolchain option for [embedded development](embedded-stm32.html) cases like using ARM or for other custom setups.

Procedure:

1. In the main menu, go to `File | Settings | Build, Execution, Deployment | Toolchains`.

2. Click ![Add toolchain](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg) and select System to add a new System toolchain.

3. Configure the tools and provide an [environment script](how-to-create-toolchain-in-clion.html#env-scripts) if required:

![System toolchain configuration example](https://resources.jetbrains.com/help/img/idea/2026.2/cl_system_toolchain_example.png)

## Initializing the toolchain environment via a script

Instead of setting the environment manually, you can point CLion to an environment file — a shell script that initializes the environment for your project. This is helpful, for example, when you need to initialize compiler variables, add custom ones, or modify the `PATH`.

The following environment files are supported:

* `bat` files — Windows MinGW and MSVC toolchains.

* `ps1` files — Windows MinGW, Cygwin, and MSVC toolchains.

* `shell` files — Windows Cygwin, Local Linux/macOS, WSL, Docker, and Remote toolchains. > **Tip:** > See [Set the fallback shell](#set-shell).

Most frameworks include environment scripts, which you can use right away. See the example of [ESP-IDF on macOS](esp-idf.html#env-vars-macos). You can also create your own script, for example, when you need to source several environment files: see the example of [ESP-IDF on Windows](esp-idf.html#env-vars-windows).

> **Note:**
> * Toolchain environment affects all steps performed with that particular toolchain, which includes CMake generation, build, and binary launch.
>
> * For all toolchains except [Docker](clion-toolchains-in-docker.html), environment sourcing only happens once: the first time the toolchain in used in a [CMake profile](cmake-profile.html) or upon loading a [Makefile](makefiles-support.html). For Docker, sourcing happens each time the toolchain is used.
>
> * When you make changes to the environment file, CLion re-sources it automatically by default. You can prevent the environment state from being automatically cached by unchecking the Cache environment from environment file based on file modified timestamps option in Settings | Advanced settings. Also, note that [resetting CMake](cmake-cache.html#reset-cache) invalidates the environment file cache.

Procedure:

1. In the toolchain settings, click Add environment, then click From file:

![Setting a script to initialize the environment](https://resources.jetbrains.com/help/img/idea/2026.2/cl_toolchain_env_script.png)

2. In the Environment file field, specify the path to the script:

![Environment initialization via a script](https://resources.jetbrains.com/help/img/idea/2026.2/cl_toolchain_env_script_file.png)

3. You will get notifications in case of script loading issues. CLion also checks the script loading time and terminates the execution if it takes too long.

![Environment script loading report](https://resources.jetbrains.com/help/img/idea/2026.2/cl_env_script_error.png)

Procedure: Set the fallback shell

* To source the environment file on Linux (local or remote), [WSL](how-to-use-wsl-development-environment-in-product.html), and [Docker](clion-toolchains-in-docker.html), CLion invokes `source` or `.` in default login shell as set in the `$SHELL` variable.

If `$SHELL` is empty, CLion uses the shell specified in the Fallback shell for sourcing the environment field of the [Advanced settings](advanced-settings.html).

## Clang compiler on Windows

With CMake [3.15](https://cmake.org/cmake/help/latest/release/3.15.html), it has become possible to use the Clang compiler on Windows with the MinGW-w64/MinGW toolchain.

However, the LLVM Clang for Windows is built using Microsoft Visual Studio, and all the built-in macros and include search paths are set up for use with Visual Studio. So if you take Clang from the [LLVM repository](https://github.com/llvm), it will not work correctly when configured with the MinGW toolchain. One of the possible workarounds is described below.

Procedure: Set up the Clang compiler for MinGW

1. Install [MSYS2](https://www.msys2.org/).

2. In the MSYS terminal, run the following [pacman](https://wiki.archlinux.org/index.php/pacman) command to download the complete [set of packages](https://packages.msys2.org/groups/mingw-w64-clang-x86_64-toolchain) built with clang:

```CONSOLE
pacman -S mingw-w64-clang-x86_64-toolchain
```

Run one more command to get the MinGW-w64 GDB debugger:

```CONSOLE
pacman -S mingw-w64-clang-x86_64-gdb
```

3. Go to `Settings | Build, Execution, Deployment | Toolchains` and create a MinGW toolchain.

Set the Toolset to `C:\msys64\clang64`. Set other paths manually in case they are not detected automatically.

![MSYS MinGW toolchain](https://resources.jetbrains.com/help/img/idea/2026.2/cl_clang_mingw.png)

> **Note:**
> With this new toolchain configured, you can build the project and start using the Clang's advances tools, such as [profile-guided optimization](https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization). Take a look at [this blogpost](https://blog.jetbrains.com/clion/2020/12/setting-up-clang-on-windows/#using_advanced_tools_provided_by_the_clang_compiler) for instructions.

## GDB on Windows

In the case of MinGW, CLion includes the bundled GDB (version 17.1). For Cygwin, you need to install the GDB package in the Cygwin Package Manager, as described in the [Cygwin](#Cygwin) section of this guide.

You can also switch to a custom GDB binary. In this case, the supported GDB versions are 7.8.x-17.1.

Note that for GDB 8.0 and later, debugger output is redirected to CLion console by default. To enable opening an external console window for application input/output, go to Help | Find Action or press `Ctrl+Shift+A` (Windows), `⌘ ⇧ A` (macOS), `⌘ ⇧ A` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ P` (macOS System Shortcuts), `Ctrl+Shift+A` (XWin), `Ctrl+Shift+A` (GNOME), `Ctrl+Shift+A` (KDE), `Escape, X` (Emacs), `Ctrl+Shift+P` (Sublime Text), `⌘ ⇧ P` (Sublime Text (macOS)), `⌘ ⇧ A` (Xcode), `Ctrl+Shift+A` (Visual Studio), `⌘ ⇧ A` (Visual Studio (macOS)), `Ctrl+Shift+A` (ReSharper), `⌘ ⇧ A` (ReSharper (macOS)), `Ctrl+Shift+A` (QtCreator), `⌘ ⇧ A` (QtCreator (macOS)), `Ctrl+I` (NetBeans), `Ctrl+Shift+A` (Eclipse), `⌘ 3` (Eclipse (macOS)), search for Registry, and set the following key: cidr.debugger.gdb.workaround.windows.forceExternalConsole.

## See also

### How tos

[Install CLion](installation-guide.html) [Quick CMake tutorial](quick-cmake-tutorial.html) [Toolchains](how-to-create-toolchain-in-clion.html) [Compilers](how-to-switch-compilers-in-clion.html) [Working with WSL](how-to-use-wsl-development-environment-in-product.html) [Remote development](remote-development.html) [Debugger options](configuring-debugger-options.html)

### Languages, Frameworks and Technologies

[Qt Projects](qt-tutorial.html) [CUDA Projects](cuda-projects.html)

### External Links

[CLion blog: Setting up the Clang Compiler in CLion on Windows](https://blog.jetbrains.com/clion/2020/12/setting-up-clang-on-windows/)

