

- Configure visual studio cmake to run wsl compiler how to#
- Configure visual studio cmake to run wsl compiler install#
- Configure visual studio cmake to run wsl compiler update#
- Configure visual studio cmake to run wsl compiler plus#
- Configure visual studio cmake to run wsl compiler zip#
In the launch bar change the launch target from “Current Document” to your project name.ġ1. In the Solution Explorer expand the project subfolder and in the. If you are missing any other dependencies (gcc, gdb, make, rsync, zip) then see above for Setting up WSL.ĩ. If you don’t have CMake on your WSL installation, then you will be prompted to automatically deploy a recent version of CMake from Visual Studio. This will start the cache generation of your WSL configuration.Ĩ. Save the editor (Ctrl + S) and select your WSL-GCC-Debug configuration as your active configuration using the configuration drop-down menu at the top of the page. Scroll down to the bottom of the CMake Settings Editor and click the link to “Show advanced settings”. If you are using Visual Studio 2019 version 16.6 or later, then Visual Studio will attempt to use Ninja by default. If you have side-by-side installations of WSL, then you can specify which WSL executable Visual Studio should use by setting the “Path to WSL executable” property under the “General” section of the CMake Settings Editor.Ħ. By default, Visual Studio will pick up on your default WSL configuration. If you are building with Clang, then you can select a WSL-Clang-Debug or WSL-Clang-Release configuration.ĥ.
Configure visual studio cmake to run wsl compiler plus#
You can add a new WSL configuration by clicking on the green plus sign above the configuration manager on the left-hand side of the editor.Ĥ. Visual Studio creates an 圆4-Debug configuration by default. Navigate to the configuration drop-down menu and select “Manage Configurations…” This will open the CMake Settings Editor.ģ. Start Visual Studio 2019 (version 16.1 or later) and create a new CMake project using the “CMake Project” template or open an existing one.Ģ.

Let’s start by looking at a simple CMake project.ġ. This is a one-time operation that Visual Studio performs to configure IntelliSense for Linux connections. Due to the lack of visibility into the root file system of WSL from Windows, a local rsync copy is done inside WSL to copy the headers to a Windows visible location.
Configure visual studio cmake to run wsl compiler zip#
The inclusion of rsync and zip allows Visual Studio to extract header files from your WSL instance to the Windows filesystem to use for IntelliSense. In this tutorial, I’ll use GCC and Unix Makefiles.
Configure visual studio cmake to run wsl compiler install#
Sudo apt install g++ gdb make ninja-build rsync zip
Configure visual studio cmake to run wsl compiler update#
You can install them on distros that use apt with the following commands: sudo apt update

If you are using CMake, then you will also need to install an underlying build system (Ninja or Unix Makefiles). To configure your WSL installation to work with Visual Studio you need the following tools installed: a compiler (GCC or Clang), gdb, rsync, and zip.
Configure visual studio cmake to run wsl compiler how to#
You can find details on how to install WSL here, but the easiest way is to download your distro of choice (Ubuntu, Debian, etc.) from the Microsoft Store. Stay tuned to the C++ Team Blog for more information on our WSL2 support. To avoid these slowdowns, you can install and run SSH on your local WSL2 installation and add a new SSH connection to WSL2 as if it were a remote machine. Learn more about the differences between WSL1 and WSL2 here. These commands are slower with WSL2 because performance across the Windows and Linux operating systems is faster in WSL1 than WSL2. mnt/c/Users…) to access local source files from WSL. Our support executes all commands locally through wsl.exe and relies on Windows drives mounted under the /mnt folder (e.g. Our native support for WSL works best with WSL1. If you are just getting started with our native support for CMake, be sure to check out our CMake Support in Visual Studio introductory page too. We recommend using CMake for all C++ cross-platform development. We will then walk-through how to use it with a CMake project and a MSBuild-based Linux project. In this blog post, we’ll first look at how to set up WSL. This will save you time getting up and running in a Linux environment and eliminates the need to copy and maintain sources on a remote machine. In order to use our native support for WSL you will need to install the Linux Development with C++ workload in Visual Studio. In Visual Studio you no longer need to add a remote connection or configure SSH in order to build and debug on your local WSL installation. WSL lets you run a lightweight Linux environment directly on Windows, including most command-line tools, utilities, and applications. Visual Studio 2019 version 16.1 added native support for using C++ with the Windows Subsystem for Linux (WSL). For up-to-date documentation see Walkthrough: Build and Debug C++ with Microsoft Windows Subsystem for Linux 2 (WSL 2) and Visual Studio 2022.įor an overview of the Visual Studio capabilities described in this article, see Develop C and C++ applications.This post was updated on December 11, 2020
