CLion and Linux toolchain on Windows are now friends!
In this post we’ll discuss how to work with WSL in CLion and how Windows users can benefit from this support.
Why do I need it?
CLion is a cross-platform IDE, that means you can run it on Windows, Linux, and macOS. From the very beginning it works with GCC and Clang compilers, which means on Windows it requires Cygwin or MinGW (or MinGW-w64). Later we introduced Microsoft Visual C++ compiler support, for those users who have it installed and want to use inside CLion on Windows.
Besides, we know that there are C++ developers who have Windows desktops but require Linux toolchain for building their projects. Cygwin could be a work-around. With Windows 10 Microsoft however introduced an even better way – Windows Subsystem for Linux. You simply get the prefered Linux distribution (Ubuntu, OpenSUSE and SLES are supported), configure the WSL and enjoy your new Linux environment in Windows. And now you can benefit from it in CLion!
That means the following is possible:
- Configure WSL toolchains in CLion on Windows
- Use CMake, C, and C++ compilers from Linux in CLion running on your Windows machine
- Debugger support is available
- Catch memory errors and leaks right from the IDE with the Valgrind Memcheck integration
Windows Subsystem for Linux (WSL) is a compatibility layer for running Linux binary executables natively on Windows 10. Let’s start with the simple instruction on how to set it all up:
- Update your Windows 10 machine to the latest “Fall Creators Update” (mininum version 1709, build 16299.15).
- Install WSL distribution, for instance Ubuntu.
- Run Ubuntu, create a new user, keep in mind username:password.
- Setup Ubuntu WSL environment:
- install cmake, gcc, or/and clang,
- configure and run openssh-server.
Check ubuntu_setup_env.sh script that can help you with the configuration:
wget https://raw.githubusercontent.com/JetBrains/clion-wsl/master/ubuntu_setup_env.sh && bash ubuntu_setup_env.sh
If you are using Linux distribution different from Ubuntu, you might need some adjustments to the script.
- To check the ssh connection, run the follow command in your WSL distribution: ssh username@localhost -p <port_number> (2222 in case of our script)
Full instruction on our confluence page.
Configure WSL toolchain in CLion
Starting with the CLion 2018.1 EAP you can use WSL as a toolchain in CLion. Go to Build, Execution, Deployment | Toolchains and select WSL in the environments dropdown:
Configure remote credentials (provide port, username and password):
Check if everything is connected and working, CMake, C, and C++ compilers are detected and available to use:
Known issues and limitations
- There is a known issue is with the mixed case-sensitivity. 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 pass properties (Help -> “Edit Custom Properties…”): idea.case.sensitive.fs=true, restart an IDE and rebuild the project index (File -> “Invalidate Caches and Restart”) after that.
That’s it! And a short demo at the end:
WSL support is a first step to implement full remote development support in CLion. It’s planned to work over ssh, just the same way the WSL now works in CLion, and will be available on all platforms.
We encourage our Windows users to try out the new WSL toolchains support in CLion, and report any issues they find to our bug tracker.
Your CLion Team
The Drive to Develop
Subscribe to Blog updates
Thanks, we've got you!