Visual studio enterprise linux

Download, install, and set up the Linux workload

Linux projects are supported in Visual Studio 2017 and later. To see the documentation for these versions, set the Visual Studio Version selector control for this article to Visual Studio 2017 or Visual Studio 2019. It’s found at the top of the table of contents on this page.

You can use 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 can work on your existing code base that uses CMake without having to convert it to a Visual Studio project. 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 code on Windows using Visual Studio. Then, quickly retarget the project for Linux to build and debug in a Linux environment. 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

Type «Visual Studio Installer» in the Windows search box:

Look 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.

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

Click Modify to continue with the installation.

Options for creating a Linux environment

If you don’t already have a Linux machine, you can create a Linux Virtual Machine on Azure. For more information, see Quickstart: Create a Linux virtual machine in the Azure portal.

On Windows 10 and later, you 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 10. If you’re unable to access the Windows Store, you can manually download the WSL distro packages. WSL is a convenient console environment, but it’s not recommended for graphical applications.

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

  • A compiler — Visual Studio 2019 has full support for GCC and Clang.
  • gdb — Visual Studio automatically launches gdb on the Linux system, and uses the front end of the Visual Studio debugger to provide a full-fidelity debugging experience on Linux.
  • rsync and zip — the inclusion of rsync and zip allows Visual Studio to extract header files from your Linux system to the Windows filesystem for use by IntelliSense.
  • make
  • openssh-server (remote Linux systems only) — Visual Studio connects to remote Linux systems over a secure SSH connection.
  • CMake (CMake projects only) — You 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 2019 version 16.6 or later.
Читайте также:  Как увидеть все папки windows

The following commands assume you’re using g++ instead of clang.

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

  • gcc — Visual Studio 2017 has full support for GCC.
  • gdb — Visual Studio automatically launches gdb on the Linux system and uses the front end of the Visual Studio debugger to provide a full-fidelity debugging experience on Linux.
  • rsync and zip — the inclusion of rsync and zip allows Visual Studio to extract header files from your Linux system to the Windows filesystem to use for IntelliSense.
  • make
  • openssh-server — Visual Studio connects to remote Linux systems over a secure SSH connection.
  • CMake (CMake projects only) — You can install Microsoft’s statically linked CMake binaries for Linux.

Linux setup: Ubuntu on WSL

When you’re targeting WSL, there’s no need to add a remote connection or configure SSH to build and debug. zip and rsync are required for automatic syncing of Linux headers with Visual Studio for Intellisense support. ninja-build is only required for CMake projects. If the required applications aren’t already present, you can install them using this command:

Ubuntu on remote Linux systems

The target Linux system must have openssh-server, g++, gdb, and make installed. ninja-build is required for CMake projects only. The ssh daemon must be running. zip and rsync are required for automatic syncing of remote headers with your local machine for Intellisense support. If these applications aren’t already present, you can install them as follows:

At a shell prompt on your Linux computer, run:

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

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

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

Fedora on WSL

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

zip and rsync are required for automatic syncing of Linux headers with Visual Studio for Intellisense support. ninja-build is only required for CMake projects.

Fedora on remote Linux systems

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

At a shell prompt on your Linux computer, run:

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

Читайте также:  Windows cmd with tabs

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

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

Next Steps

You’re now ready to create or open a Linux project and configure it to run on the target system. For more information, see:

Источник

Загрузка, установка и настройка рабочей нагрузки Linux

Проекты Linux поддерживаются в Visual Studio версии 2017 и выше. Чтобы увидеть документацию для этих версий, установите в данной статье селектор Версия Visual Studio в Visual Studio 2017 или Visual Studio 2019. Он находится в верхней части оглавления на этой странице.

Вы можете использовать интегрированную среду разработки Visual Studio в Windows для создания, редактирования и отладки проектов C++, которые выполняются в удаленной системе Linux, на виртуальной машине или в подсистеме Windows для Linux.

Вы можете работать с имеющейся базой кода, где CMake не требуется преобразовывать в проект Visual Studio. Если база кода является кроссплатформенной, в Visual Studio можно создавать решения как для Windows, так и для Linux. Например, с помощью Visual Studio можно редактировать, выполнять сборку и отлаживать свой код в Windows. Затем можно быстро перенацелить проект для Linux на сборку и отладку в среде Linux. Файлы заголовков Linux автоматически копируются на ваш локальный компьютер. Visual Studio использует их для обеспечения полной поддержки технологии IntelliSense (завершение операторов, переход к определению и т. д.).

Чтобы использовать любой из этих сценариев, требуется рабочая нагрузка Разработка для Linux на C++ .

Установка Visual Studio

В поле поиска Windows введите «Visual Studio Installer»:

Найдите установщик в разделе Приложения и дважды щелкните его. Когда откроется установщик, щелкните Изменить и перейдите на вкладку Рабочие нагрузки. Прокрутите вниз до раздела Другие наборы инструментов и выберите рабочую нагрузку Разработка для Linux на C++ .

Если вы используете внедренную платформу или платформу Интернета вещей, перейдите в панель Сведения об установке, которая находится справа. В разделе Разработка для Linux на C ++ разверните узел Необязательные компоненты и выберите нужные компоненты. Поддержка CMake для Linux включена по умолчанию.

Для продолжения установки нажмите кнопку Изменить.

Варианты создания среды Linux

Если у вас нет компьютера Linux, можно создать виртуальную машину Linux в Azure. Дополнительные сведения см. в разделе Краткое руководство. Создание виртуальной машины Linux на портале Azure.

В Windows 10 можно установить и настроить использование определенного дистрибутива Linux в подсистеме Windows для Linux (WSL). См. подробнее руководство по установке подсистемы Windows для Linux в Windows 10. Если не удается получить доступ к Microsoft Store, можете вручную скачать пакеты дистрибутивов WSL. WSL — это удобная консольная среда, но ее не рекомендуется использовать для графических приложений.

Для проектов Linux в Visual Studio необходимо установить следующие зависимости в удаленной системе Linux или WSL:

  • Компилятор — Visual Studio 2019 полностью поддерживает GCC и Clang.
  • gdb — Visual Studio автоматически запускает gdb в системе Linux и использует интерфейс отладчика Visual Studio для обеспечения всех возможностей отладки в Linux.
  • rsync и zip — благодаря включению rsync и zip Visual Studio может извлекать файлы заголовков из системы Linux в файловую систему Windows для использования технологией IntelliSense.
  • make
  • openssh-server (только удаленные системы Linux) — Visual Studio подключается к удаленным системам Linux через безопасное SSH-соединение.
  • CMake (только для проектов CMake) — вы можете установить статически связанные двоичные файлы CMake для Linux.
  • ninja-build (только для проектов CMake) — Ninja является генератором по умолчанию для конфигураций Linux и WSL в Visual Studio 2019 версии 16.6 или более поздней версии.
Читайте также:  Sccm client windows 10

В следующих командах предполагается, что вы используете g++ вместо clang.

Для проектов Linux в Visual Studio необходимо установить следующие зависимости в удаленной системе Linux или WSL:

  • gcc — Visual Studio 2017 полностью поддерживает GCC.
  • gdb — Visual Studio автоматически запускает gdb в системе Linux и использует интерфейс отладчика Visual Studio для обеспечения всех возможностей отладки в Linux.
  • rsync и zip — благодаря включению rsync и zip Visual Studio может извлекать файлы заголовков из системы Linux в файловую систему Windows для использования технологией IntelliSense.
  • make
  • openssh-server — Visual Studio подключается к удаленным системам Linux через защищенное SSH-соединение.
  • CMake (только для проектов CMake) — вы можете установить статически связанные двоичные файлы CMake для Linux.

Установка Linux: Использование Ubuntu в WSL

Если вы используете WSL, для сборки и отладки не требуется добавлять удаленное подключение или настраивать SSH. Использование zip и rsync является обязательным для автоматической синхронизации заголовков Linux в Visual Studio и включения поддержки Intellisense. ninja-build требуется только для проектов CMake. Если необходимые приложения отсутствуют, их можно установить с помощью следующей команды:

Использование Ubuntu в удаленных системах Linux

В целевой системе Linux должны быть установлены openssh-server, g++ , gdb и make. ninja-build требуется только для проектов CMake. Должна быть запущена управляющая программа ssh. Использование zip и rsync необходимо для автоматической синхронизации удаленных заголовков на локальном компьютере, чтобы обеспечить поддержку Intellisense. Если этих приложений еще нет, их можно установить следующим образом.

В командной строке оболочки на компьютере Linux выполните следующую команду:

Для выполнения команды sudo вам может быть предложено ввести пароль учетной записи root. Введите его и продолжите. После завершения будут установлены требуемые службы и средства.

Запустите службу ssh на компьютере Linux, выполнив следующую команду:

Эта команда запускает службу в фоновом режиме и в состоянии готовности к принятию подключений.

Использование Fedora в WSL

В Fedora используются установщик пакетов dnf. Чтобы скачать g++ , gdb, make, rsync, ninja-build и zip, выполните следующую команду:

Использование zip и rsync является обязательным для автоматической синхронизации заголовков Linux в Visual Studio и включения поддержки Intellisense. ninja-build требуется только для проектов CMake.

Использование Fedora в удаленных системах Linux

На целевой машине под управлением Fedora используются установщик пакетов dnf. Чтобы скачать openssh-server, g++ , gdb, make, ninja-build, rsync и zip, а затем перезапустить управляющую программу ssh, сделайте следующее: ninja-build требуется только для проектов CMake.

В командной строке оболочки на компьютере Linux выполните следующую команду:

Для выполнения команды sudo вам может быть предложено ввести пароль учетной записи root. Введите его и продолжите. После завершения будут установлены требуемые службы и средства.

Запустите службу ssh на компьютере Linux, выполнив следующую команду:

Эта команда запускает службу в фоновом режиме и в состоянии готовности к принятию подключений.

Следующие шаги

Теперь вы можете создать или открыть проект Linux, а также настроить его для выполнения в целевой системе. Дополнительные сведения можно найти в разделе

Источник

Оцените статью