CLion 2017.3 Help

How to Create Toolchain in CLion


A toolchain in CLion specifies all the necessary tools required for building and running project: working environment, compiler, building system and debugger. When you start with CLion, you have only Default toolchain available. CLion uses it to create and open a new project. Although you can use that toolchain in your development, you may want to adjust your tool sets directly for a project needs: for example, to use a compiler or working environment which is optimal for a certain task. A toolchain is an instrument for such adjustment.

Creating Toolchain

As an example, let's create a single toolchain assuming the Windows development using MinGW 32 bit as working environment.
  1. First of all, if you are a Windows user please take a look on our tutorial and make sure you have already installed all the required packages.
    Now, you need to open the Toolchains settings dialog. To do that, go to the File | Settings | Build, Execution, Deployment | Toolchains (or CLion | Preferences | Build, Execution, Deployment | Toolchains if you are macOS user):
    cl ToochainsSettings

  2. Let's add a new toolchain to the existing list. Click add button and you can see that a new toolchain appears in the list. In the Name field specify the name for that toolchain, MinGW32 for instance.
  3. As a next step, specify the desired environment. Select MinGW from the drop down list and specify MinGW home directory. CLion automatically detects it, although you can specify it explicitly by typing it in the text field. If you have several MinGW installations, you can choose the one preferred for the certain toolchain configuration. Click the expand 2x button and select the desired MinGW installation directory from the drop down list:
    cl toolchainsMinGW64
    Alternatively, you can use the browseButton button and select a path from the dialog that opens.
    CMake verifies your choice and automatically detects Make, C and C++ compilers. These installations represented in corresponding fields are not defaults, but the ones that CMake detects considering all the packages installed on your computer at that moment. If needed, you can change Make versions and compilers from detected to the most suitable for your purposes.
  4. Select the preferred CMake installation. You can use either bundled version or custom, at you choice.
  5. Select the desired Make installation and preferred C and C++ compilers.
  6. CLion verifies and confirms your choice:
    cl toolchainsMinGW64success
    If verification of any of that packages failed (e.g compiler not found), CLion notifies you about it accordingly:
    cl toolchainsMinGW64failed
  7. Finally, a few words about debugger settings. For our example (MinGW 32 bit), you have a choice between the bundled or custom GDB. Similar for masOS and Linux: you can choose between bundled LLDB and GDB (you can select custom or bundled version for the latter). Important note: if MinGW 64 bit or Cygwin is selected as environment, bundled GDB is inaccessible. You can use only custom GDB that is the MinGW (or Cygwin) component.
  8. Click Apply and OK buttons to finish the process. Now you have one more toolchain configuration that you can use when creating a build configuration.
Now you can use it when creating a CMake profile.
Last modified: 27 March 2018

See Also