Quick Tutorial: Configure CLion on Windows
Currently CLion supports the following environments that include compilers and additional sets of tools needed for the development purposes:Toolchains settings dialog ( and expand the Environment drop down list: it must contain all the environments deployed on your machine and detected by CLion. There might be cases where it will not succeed though — such as in the case of missing packages or unsupported versions.
Both the installation and upgrade of Cygwin happen from the executable you download on the Cygwin download page. After firing up the installation and choosing the install directly (e.g., c:\cygwin64 for 64-bit), you need to pick the packages to install. The packages that CLion needs are:
Alternatively, you can just install the gcc-g++ and gcc-core packages. These two packages, make and GDB have all that CLion needs.
To install a package, simply search for it in the Select Packages window and click the name until a tick mark appears in the Bin? column:
Once you’ve installed Cygwin, open CLion’s settings in Build, Execution, Deployment | Toolchains. From the drop down list of available environments, choose Cygwin. Specify the path to Cygwin or select the preferred Cygwin installation from the list. CLion will validate your settings and, if everything is OK, will present the following:and navigate to
You can use MinGW instead of Cygwin as the operating environment that CLion can use. MinGW can be installed in many ways: you can install the official distribution, the mingw-w64 distribution or, alternatively, one of the pre-made distributions such as TDM-GCC. In this guide we will take a look at the default distribution only.
To install MinGW, go to the downloads page and download
mingw-get-setup.exe. This executable will help you install all the required packages that CLion needs to operate.
Fire up the installer and pick your path (e.g.,
c:\MinGW). Now MinGW will go off and download a database that lists all available packages that can be installed. You will then be presented with the Installation Manager window where you need to pick at least the packages shown below: Now, simply choose from the menu, press Apply in the dialog that opens and wait for the packages to download and install.
Windows Subsystem for Linux
If you are a Windows 10 user (least supported version is Fall Creators Update” version 1709, build 16299.15; you can use higher versions), you can use Windows Subsystem for Linux in CLion. With WSL you can create Linux toolchains for building your project on Windows machine and operate you prefered Linux distribution at the same time. All you need is to download and install WSL on your system and select it as working environment in CLion: For more details on how to install and configure WSL refer to our manual.
Microsoft Visual C++ compiler
In addition to MinGW or Cygwin as operating environments for CLion, you can try using Microsoft Visual C++ compiler. CLion supports that compiler with CMake and NMake generator. With Microsoft Visual C++ you are able to work with the various cross-platform projects which often use Microsoft Visual Studio under Windows as a working environment.
To begin with, you need either Visual Studio 2013, 2015 or 2017 to be installed on your system. Having that, configure CLion to use Visual C++ compiler:
Set up Microsoft Visual C++ compiler as your environment. Go to the Toolchains settings dialog ( ) and select Visual Studio from the list of available environments. Note, that CLion automatically detects the Visual Studio version installed on your system.
Specify the architecture (x86, amd64, x86_arm, amd64_arm, etc), type of a platform (store or uwp or leave it blank) and version (Windows SDK name or leave it blank).
That's all. Now you can build your project with MSVC and run it. Note, that CLion will run CMake with the NMake generator in this case.
CLion tries its best to indicate whether or not a particular part of the required infrastructure is configured. If you attempt to compile without a predefined toolset, you will get an error similar to the following: Similarly, if you neglect to install one of the constituent parts, the Toolchains option page will perform the requisite validation and will indicate which part is missing:
There are two essential tools that CLion needs. First is CMake, which is used as the project/build system: think of it as an alternative to other popular build systems such as MSBuild (used by Visual Studio) or Qmake. CMake is fundamentally different to, say, Visual Studio in that CMake is not really a build system: instead, it is a build generator that produces build scripts in different formats, Visual Studio included. As a consequence, CMake does not have the equivalent notion of a solution: instead, several different binaries can be built out of a single CMakeLists.txt file as different targets.
You can find out more about CMake in our Configuring CMake guide.
CLion comes bundled with a compatible version of CMake. As an alternative, you can specify a path to your own CMake distribution. You can download a distribution of CMake here.
While CMake tries to be very generic, you can get it to perform actions specific to a particular operating system. For example, the following clause will only be invoked in a Win32 setting:
if (WIN32) #do something endif (WIN32)
GDB, the GNU Debugger, is what CLion uses for debugging your C++ applications. It is an essential part that is required by CLion to function properly.
If you are using MinGW, CLion comes with bundled GDB. Please note, however, that the option to use it is available for MinGW only; for Cygwin, you will have to install the appropriate package in the Cygwin Package Manager, as described in the Cygwin section of this guide.
Running and Debugging a Program
In order to run a program, you first need to make sure that you have both a target that gets built as well as a configuration that gets executed. A configuration is essentially a specification of what gets executed and how. If you open an existing project, a configuration will be created for each target automatically (see this tutorial for further info on run/debug configurations). If you want to change an existing configuration or create a new one, choose in the menu. The configuration editor looks as follows:
For a configuration, you need to specify the target, the CMake profile and the actual executable that you are going to run. There’s also scope for specifying additional parameters.
Once you are done, you can run a program either by choosing, pressing Shift+F10 or pressing the button in the menu bar on the top right of the window:
Note that running the app does not start a debug session. To start debugging, choose , press Shift+F9 or press the bug icon in the above menu bar. When execution pauses, an additional debugging tool window opens:
Debugging a program works the same as in other IDEs: you set the breakpoints (click on the margin or press Ctrl+F8) and then, once the debug session is initiated, execution gets paused at the breakpoint.