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
CLion 2024.1 EAP 4: Switch to CLion Nova in CLion Classic
The CLion 2024.1 EAP 4 build (241.13688.39) is out! It is available from our website, via the Toolbox App, or as a snap package if you’re using Ubuntu. With this build, we’re making CLion Nova available to all CLion Classic users. Switch to it from inside the IDE via the settings menu and try it …
CLion 2024.1 EAP 3: Assembly View Enhancements
Today, the CLion 2024.1 EAP 3 build (241.12662.59) is available from our website, via the Toolbox App, or as a snap package if you’re using Ubuntu. Here are the main improvements: Assembly view improvements: The Assembly view for ARM targets is now shown correctly (CPP-36901). Assembly vi…
CLion 2024.1 EAP 2: Improved Terminal and Other UX Enhancements
Some time ago, we shared our plans and directions. Just a couple of weeks ago, we kicked off our CLion 2024.1 EAP with CMake coding assistance, code analysis in device tree files, and forked processes debugging. Today, the CLion 2024.1 EAP 2 build (241.11761.23) is available from our website, via…
CLion Nova: AI Assistant and Enhancements From CLion Classic and ReSharper v2024.1
CLion Nova is a free preview of CLion equipped with the ReSharper C++/Rider C++ language engine. With this update, CLion Nova has finally moved to the 2024.1 branch. This means that all of the enhancements brought by the CLion Classic 2024.1 EAP are now available in CLion Nova: CMake writing ass…