CLion 2020.1 Help

Quick Tutorial: Configure CLion on Windows

On Windows, configuring CLion requires setting up the environment: Cygwin, MinGW, WSL, or Microsoft Visual C++. You can have several environments installed on your system and create separate CLion toolchains for each of them. As a determining part of a toolchain, the environment provides C and C++ compilers, the make utility, and the debugger (in case of using default tools).

For details on Remote Host toolchains, see Full Remote Mode.

MinGW

  1. Download and run the MinGW or MinGW-W64 installer.

  2. In the MinGW installer, select the following packages from the Basic Setup list: mingw-developer-tool, mingw32-base, mingw32-gcc-g++, mingw32-msys-base.

    MinGW installation

  3. Once the installation is finished, open CLion and go to File | Settings | Build, Execution, Deployment | Toolchains. Choose the toolchain that you want to configure.

  4. Select MinGW from the Environment list. CLion will attempt to detect the MinGW installation automatically. Check the detection result, and specify the path manually if required.

  5. Wait until the tools detection finishes. If CLion cannot detect compilers or make, double-check the installed packages in MinGW Installation Manager. Press Apply when all the tools are set correctly.

    MinGW toolchain

Cygwin

  1. Download the Cygwin installer, version 2.8 or later.

  2. Run the installer and select the following packages:

    • gcc-g++
    • make
    • gdb

    To select a package, type its name in the Search field and then click it in the list until a tick mark appears in the Bin? column:

    Cygwin installation

  3. Once the installation is finished, open CLion and go to File | Settings | Build, Execution, Deployment | Toolchains. Choose the toolchain that you want to configure.

  4. Select Cygwin from the Environment list. CLion will attempt to detect the Cygwin installation automatically. Check the detection result, and specify the path manually if required.

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

    Cygwin toolchain

Windows Subsystem for Linux

You can use WSL, 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 leaving CLion running on your Windows machine.

Refer to our WSL guide for details on setting up WSL on your system and configuring WSL toolchains in CLion.

WSL toolchain

Microsoft Visual C++

MSVC compiler

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

Note that msbuild is not supported: CLion runs CMake with the NMAKE generator instead.

  1. Install Visual Studio 2013, 2015, 2017, or 2019 on your system.

  2. In CLion, go to File | Settings | Build, Execution, Deployment | Toolchains and choose the toolchain that you want to configure.

  3. Select Visual Studio from the Environment list. CLion will attempt to automatically detect the installed Visual Studio distribution. If the detection fails, set the path to Visual Studio manually.

  4. 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.

  5. Wait until the tools detection is finished:

    MSVC toolchain

For the case when your code includes MSVC extensions, 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's -fms-extensions flag.

Clang-cl compiler

As an alternative compiler, you can use clang-cl - the MSVC-compatible compiler driver for Clang. CLion supports clang-cl version 8.0 and later.

  1. Install clang-cl from the LLVM site 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 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

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).

LLDB-based MSVC debugger

The MSVC toolchain debugger is implemented on top of LLDB. It can work with native visualizers from the Visual Studio installation or from your project. To enable native visualizers support and set the desired diagnostics level, select Enable NatVis renderers for LLDB in Settings | Build, Execution, Deployment | Debugger | Data Views | C/C++:

MSVC NatVis

Also, if you have custom native visualizers in your project, CLion will use them as well:

MSVC debug with custom NatVis

GDB on Windows

In the case of MinGW, CLion includes the bundled GDB (version 8.3). For Cygwin, you need to install the GDB package in the Cygwin Package Manager, as described in the 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-8.3.x.

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, search for Registry, and set the following key: cidr.debugger.gdb.workaround.windows.forceExternalConsole.

Last modified: 25 June 2020