Download, install, and set upward the Linux workload

Linux projects are supported in Visual Studio 2022 and later. To see the documentation for these versions, prepare the Visual Studio Version selector control for this article to Visual Studio 2022 or Visual Studio 2022. It's found at the summit of the table of contents on this page.

You can apply the Visual Studio IDE on Windows to create, edit, and debug C++ projects that execute on a remote Linux system, virtual machine, or the Windows Subsystem for Linux.

You tin can work on your existing code base that uses CMake without having to catechumen information technology to a Visual Studio projection. If your code base is cross-platform, you can target both Windows and Linux from within Visual Studio. For example, you can edit, build, and debug your lawmaking on Windows using Visual Studio. So, quickly retarget the projection for Linux to build and debug in a Linux environs. Linux header files are automatically copied to your local machine. Visual Studio uses them to provide full IntelliSense support (Statement Completion, Go to Definition, and so on).

For any of these scenarios, the Linux development with C++ workload is required.

Visual Studio setup

  1. Type "Visual Studio Installer" in the Windows search box:

    Screenshot showing the Windows search box.

  2. Await for the installer under the Apps results and double-click it. When the installer opens, choose Modify, and then click on the Workloads tab. Scroll down to Other toolsets and select the Linux development with C++ workload.

    Screenshot showing the Visual C++ for Linux Development workload item in Visual Studio Installer.

  3. If you lot're targeting IoT or embedded platforms, go to the Installation details pane on the correct. Under Linux evolution with C++, expand Optional Components, and choose the components you need. CMake support for Linux is selected by default.

  4. Click Modify to continue with the installation.

Options for creating a Linux environment

If you lot don't already have a Linux machine, you tin create a Linux Virtual Machine on Azure. For more information, encounter Quickstart: Create a Linux virtual machine in the Azure portal.

On Windows 10 and later, yous can install and target your favorite Linux distro on the Windows Subsystem for Linux (WSL). For more information, see Windows Subsystem for Linux Installation Guide for Windows x. If you're unable to access the Windows Shop, you can manually download the WSL distro packages. WSL is a user-friendly console environment, but it's not recommended for graphical applications.

Linux projects in Visual Studio require the following dependencies to exist installed on your remote Linux system or WSL:

  • A compiler - Visual Studio 2022 and later on take full support for GCC and Clang.
  • gdb - Visual Studio automatically launches gdb on the Linux organization, and uses the forepart cease of the Visual Studio debugger to provide a full-fidelity debugging experience on Linux.
  • rsync and zip - the inclusion of rsync and nix allows Visual Studio to excerpt header files from your Linux arrangement to the Windows filesystem for use past IntelliSense.
  • make
  • openssh-server (remote Linux systems only) - Visual Studio connects to remote Linux systems over a secure SSH connectedness.
  • CMake (CMake projects simply) - You lot can install Microsoft's statically linked CMake binaries for Linux.
  • ninja-build (CMake projects only) - Ninja is the default generator for Linux and WSL configurations in Visual Studio 2022 version 16.half-dozen or subsequently.

The following commands assume yous're using g++ instead of clang.

Linux projects in Visual Studio require the following dependencies to be installed on your remote Linux arrangement or WSL:

  • gcc - Visual Studio 2022 has full support for GCC.
  • gdb - Visual Studio automatically launches gdb on the Linux organization and uses the front of the Visual Studio debugger to provide a total-fidelity debugging experience on Linux.
  • rsync and cypher - the inclusion of rsync and zip allows Visual Studio to extract header files from your Linux arrangement to the Windows filesystem to use for IntelliSense.
  • brand
  • openssh-server - Visual Studio connects to remote Linux systems over a secure SSH connexion.
  • CMake (CMake projects but) - Yous tin can install Microsoft'south statically linked CMake binaries for Linux.

Linux setup: Ubuntu on WSL

When you're targeting WSL, in that location's no need to add a remote connexion or configure SSH to build and debug. aught and rsync are required for automated syncing of Linux headers with Visual Studio for Intellisense support. ninja-build is merely required for CMake projects. If the required applications aren't already present, you lot tin install them using this control:

                sudo apt-get install g++ gdb make ninja-build rsync zero                              

Ubuntu on remote Linux systems

The target Linux system must take openssh-server, g++, gdb, and brand installed. ninja-build is required for CMake projects only. The ssh daemon must be running. zip and rsync are required for automated syncing of remote headers with your local automobile for Intellisense support. If these applications aren't already nowadays, you tin install them as follows:

  1. At a trounce prompt on your Linux calculator, run:

                        sudo apt-get install openssh-server g++ gdb make ninja-build rsync naught                                      

    You may exist prompted for your root password to run the sudo command. If and so, enter it and continue. Once complete, the required services and tools are installed.

  2. Ensure the ssh service is running on your Linux computer by running:

                        sudo service ssh start                                      

    This command starts the service and runs it in the background, ready to accept connections.

Fedora on WSL

Fedora uses the dnf bundle installer. To download g++, gdb, make, rsync, ninja-build, and nothing, run:

                sudo dnf install gcc-g++ gdb rsync ninja-build brand nada                              

zero and rsync are required for automatic syncing of Linux headers with Visual Studio for Intellisense back up. ninja-build is just required for CMake projects.

Fedora on remote Linux systems

The target auto running Fedora uses the dnf package installer. To download openssh-server, thousand++, gdb, make, ninja-build, rsync, and zip, and restart the ssh daemon, follow these instructions. ninja-build is simply required for CMake projects.

  1. At a shell prompt on your Linux computer, run:

                        sudo dnf install openssh-server gcc-g++ gdb ninja-build make rsync zip                                      

    You may be prompted for your root countersign to run the sudo command. If so, enter it and go on. Once consummate, the required services and tools are installed.

  2. Ensure the ssh service is running on your Linux estimator by running:

                        sudo systemctl start sshd                                      

    This command starts the service and runs it in the background, set up to accept connections.

Next Steps

Yous're at present ready to create or open up a Linux project and configure it to run on the target arrangement. For more information, see:

  • Create a new Linux MSBuild C++ project
  • Configure a Linux CMake project