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.
As 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.
- If you have selected WSL as working environment, you need to specify
sshcredentials. Click the to set username, password and port number. User name and password shall be the same as you entered during WSL set up procedure.
- 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 those packages failed (e.g compiler not found), CLion notifies you accordingly:
- 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.
- 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.