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 ToolchainAs an example, let's create a single toolchain assuming the Windows development using MinGW 32 bit as working environment.
- 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 (or if you are macOS user):
- Let's add a new toolchain to the existing list. Click 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.
- 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 button and select the desired MinGW installation directory from the drop down list: Alternatively, you can use the 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.
- Select the preferred CMake installation. You can use either bundled version or custom, at you choice.
- Select the desired Make installation and preferred C and C++ compilers.
- CLion verifies and confirms your choice: If verification of any of that packages failed (e.g compiler not found), CLion notifies you about it accordingly:
- 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.
- 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.