CLion 2018.1 Help

How to Create Toolchain in CLion

Basics

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. If you have selected WSL as working environment, you need to specify ssh credentials. Click the browseButton to set username, password and port number. User name and password shall be the same as you entered during WSL set up procedure.
    cl WSL Credentials
  5. Select the preferred CMake installation. You can use either bundled version or custom, at you choice.
  6. Select the desired Make installation and preferred C and C++ compilers.
  7. CLion verifies and confirms your choice:
    cl toolchainsMinGW64success
    If verification of any of those packages failed (e.g compiler not found), CLion notifies you accordingly:
    cl toolchainsMinGW64failed
  8. Finally, a few words about the debugger settings. For our example (MinGW 32 bit), you have a choice between the bundled or custom GDB. Similar to that, you can choose between the bundled LLDB and GDB if using masOS or Linux. Important note: if MinGW 64 bit or Cygwin is selected as the environment, the bundled GDB is inaccessible. You can use only the custom GDB that is the MinGW (or Cygwin) component.
  9. 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: 30 May 2018

See Also