How to Use WSL Development Environment in CLion
Introduction
Suppose you need to use Linux toolchain to build a project on your Windows machine. You can use Cygwin for that, but now you can 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.
Getting started with WSL
Let’s start with the simple instruction on how to set up the WSL environment in CLion:
-
Download and install WSL distribution (for instance, Ubuntu) from Microsoft Store
- Run Ubuntu. Note: 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 the following:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
- Restart your computer.
- Open Windows Power Shell as Administrator and run the following:
- Create a new user and specify your user name and password.
- Set up 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.
wget https://raw.githubusercontent.com/JetBrains/clion-wsl/master/ubuntu_setup_env.sh && bash ubuntu_setup_env.sh
- Install cmake, gcc, or/and clang (and optionally
- Next, check up the
ssh
connection:Note: port number 2222 is valid for our configuration script. If you are not using our script, the port number can be different.ssh username@localhost -p2222
- Now you can run CLion and create a toolchain for WSL:
Current issues and limitations:
Due to the IntelliJ platform issue, there is an issue with WSL file-system which is case-sensitive and Windows FS which is not. As workaround you can do the following:
- Go to
idea.case.sensitive.fs=true
menu option and specify the following: - Invalidate caches and restart the IDE using menu option.