April 11th, 2017
0 reactions

Linux development with C++ in Visual Studio

Principal Product Manager

Content outdated

For up-to-date documentation see Linux development with C++.

For 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

Visual Studio 2017 introduced the Linux Development with C++ workload. We generally recommend Visual Studio’s native support for CMake for all C++ Linux development. Visual Studio’s CMake support allows you to target multiple platforms (Windows, a remote Linux system, the Windows Subsystem for Linux, embedded targets…) with a single CMake project. You can learn more about CMake projects in our documentation and on our C++ Team Blog.

This post describes how to use Visual Studio’s MSBuild-based support to build and debug on a remote Linux system with Visual Studio 2019. If you are looking to target both Windows and Linux with the same project, our recommendation is to use CMake.

In this post, you will learn:

  • How to acquire the Linux Development with C++ workload,
  • How to create a MSBuild-based Linux C++ project,
  • How to establish your first connection to a Linux machine from Visual Studio,
  • How sources are managed between Visual Studio and Linux,
  • What capabilities the Linux project system provides, and
  • How to use Visual Studio diagnostic tools to find and resolve issues.

If you are new to using Visual Studio for C++ development, a great starting point is our guide to Getting Started with Visual Studio.

Install Workload for Linux development with C++

Visual Studio 2017 and 2019 include the C/C++ Linux Development workload. To install it, start the Visual Studio installer and choose to either install or modify an existing installation. Scroll to the bottom. Under the section “Other Toolsets” you will find Linux Development with C++. The workload installs in under 10 minutes. Learn more about installing the Linux development with C++ workload in our documentation.

Linux Workload

Opening projects

You will need a Linux machine, or you can use the Windows Subsystem for Linux. You can use any Linux distribution that has SSH, gdb, rsync, zip, and a compiler (clang or GCC) installed. In a Debian-based Linux environment, this is as easy as:

sudo apt update
sudo apt install -y build-essential gdb rsync zip openssh-server

Start SSH with the following command:

sudo service start ssh

Learn more about options for creating a Linux environment in our documentation.

To create a new MSBuild-based Linux Console Application in Visual Studio, filter the language to C++, the platform to Linux, and select “Console Application”.