CLion 2018.3 Help

WSL

Suppose you need to use Linux toolchain to build a project on your Windows machine. You can use Cygwin for that, or try another solution - Microsoft Subsystem for Linux (WSL). WSL is a compatibility layer for running Linux binary executables natively on Windows 10. For now, it supports Ubuntu, OpenSUSE and SLES distributions.

With WSL deployed on your system, you are able to use CMake, C and C++ compilers from Linux in CLion running on your Windows machine.

Get started with WSL

  1. Download and install WSL distribution (for instance, Ubuntu) from Microsoft Store:

  2. Run Ubuntu.

    Note that upon the first lunch of Ubuntu the system may prompt you to enable the Windows optional feature. In this case, you need to:

    • Open Windows Power Shell as Administrator and run

      Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

    • Restart your computer.

  3. Set up the WSL Ubuntu environment:

    • Install cmake, gcc, or/and clang (and optionally build-essentials package), as follows:

      sudo apt-get install cmake gcc clang gdb build-essential

    • Configure and run open ssh-server.

      You can set the configuration manually or by using our script (note that if your Linux distribution is different from Ubuntu, the script might need adjustments). To download and run the script, use the following command line:

      wget https://raw.githubusercontent.com/JetBrains/clion-wsl/master/ubuntu_setup_env.sh && bash ubuntu_setup_env.sh

  4. Next, check up the ssh connection:

    ssh username@localhost -p2222

    Port number 2222 is valid for our configuration script. If you are not using our script, the port number can be different.

  5. Now you can run CLion and create a toolchain for WSL:

    cl WSL Credentials

Troubleshooting

If you get the Credentials are not valid for this WSL distribution error when creating a toolchain, check the value of HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss{ubuntu_id}\BasePath in the Windows Registry Editor (to access it, launch regedit from the Start menu). In case the value contains non-ASCII characters, use the workaround described in this issue.

Current issues and limitations

Due to the IntelliJ platform issue, there are problems with using WSL file-system which is case-sensitive and Windows file system which is not. As a workaround, you can do the following:

  • Go to Help | Edit Custom properties... menu option and specify

    idea.case.sensitive.fs=true

  • Invalidate caches and restart the IDE using File | Invalidate Caches and Restart menu option.

Last modified: 15 February 2019