# 远程开发

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/zh-cn/help/clion/llms.txt).

在 CLion 中有几种远程开发选项，每种选项针对特定的设置：

* [使用轻量客户端的远程（使用 JetBrains Gateway）](remote.html)，

* [使用本地源的远程](remote-projects-support.html)，

* [WSL2](how-to-use-wsl-development-environment-in-product.html)，

* [Docker](clion-toolchains-in-docker.html)（本地运行*），

* 以及两种 gdbserver/lldb-server 调试变体， [远程调试](remote-debug.html)（GDB/LLDB）和 [远程 GDB 服务器](remote-gdb-server.html)（仅 GDB）。

> **Tip:**
> * 如果您正在使用远程运行的 Docker 容器，请使用 Gateway 的远程或本地源的远程。 请注意，CLion 不提供对远程容器的 Docker 集成支持。

观看此 [网络研讨会录制](https://blog.jetbrains.com/clion/2022/08/5-approaches-to-remote-cpp-dev/)，并参考下表以获取 CLion 中远程开发选项的摘要：

[Video](https://www.youtube.com/v/7qMk79sIv5U)

下表可以帮助您根据各种因素决定选择哪种远程选项，例如本地操作系统和远程操作系统的组合、您正在使用的项目模型、是否需要在目标上构建等。

## 远程选项：系统和 IDE 配置

Procedure: Gateway 与本地源远程的对比

|  |    通过网关远程连接    |    远程与本地源    |
| --- | --- | --- |
|    IDE 运行中    |  远程  |  本地  |
|    本地操作系统    |  macOS / Linux / Windows  |  macOS / Linux / Windows  |
|    远程操作系统    |  Linux，包括 WSL2  |  Linux  |
|    连接协议    |  SSH / Space 集成 / Gitpod  |  SSH  |
|    必需工具    |     本地计算机上的 CLion 或 [独立 Gateway](jetbrains-gateway.html)，       远程计算机上的 CLion（可通过 Gateway 安装）     |     适用于 macOS / Linux 客户端的 [rsync](https://rsync.samba.org/)；       [Windows 客户端的 rsync](https://rsync.samba.org/) 或 [tar](https://www.gnu.org/software/tar/)     |
|    源代码位置    |  远程  |  本地  |
|    同步    |  不需要  |     所有源的自动化；       手动 [重新同步头文件搜索路径](remote-projects-support.html#resync)     |
|    构建    |  远程  |  远程  |
|    运行/调试    |  远程  |  远程  |

Procedure: WSL2 和 Docker

|  |    WSL2    |    Docker    |
| --- | --- | --- |
|    本地操作系统    |  Windows  |  macOS / Linux / Windows  |
|    远程操作系统    |  某些 [Linux 发行版](https://docs.microsoft.com/windows/wsl/install-win10#windows-10-fall-creators-update-and-later-install-from-the-microsoft-store)  |  容器化的操作系统发行版  |
|    连接协议    |  -  |  适用于操作系统的 Docker  |
|    源代码位置    |  本地  |  挂载的文件夹  |
|    同步    |  不需要  |  自动化  |
|    构建    |  在 WSL 上  |  在容器内  |
|    运行/调试    |  在 WSL 上  |  在容器内  |

Procedure: 远程调试

|  |    远程调试    |    远程 GDB 服务器    |
| --- | --- | --- |
|    本地操作系统    |     适用于 GDB 的 macOS / Linux / Windows；       适用于 LLDB 的 macOS / Linux     |  macOS / Linux / Windows  |
|    远程操作系统    |     支持 gdbserver 的任何操作系统（适用于 GDB）；       支持 lldb-server 的 macOS / Linux 或其他操作系统（适用于 LLDB）     |  支持 gdbserver 和 SSH 的任何操作系统  |
|    连接协议    |  TCP / UDP 或串行线路  |     TCP / UDP 或串行线路；       用于上传的 SSH     |
|    必需工具    |  [gdbserver](https://sourceware.org/gdb/onlinedocs/gdb/Server.html) 或 [lldb-server](https://lldb.llvm.org/man/lldb-server.html) 在目标上  |  [gdbserver](https://sourceware.org/gdb/onlinedocs/gdb/Server.html) 在目标上  |
|    源代码位置    |     本地；       符号文件也放置在本地     |  本地  |
|    同步    |  手册  |  适用于二进制文件的自动化  |
|    构建    |  未指定  |  本地（需要交叉编译）  |
|    运行/调试    |     程序在 gdbserver/lldb-server 下远程运行；       CLion 的 GDB/LLDB 连接到正在运行的进程并在本地调试     |     程序在 gdbserver 下远程运行；       CLion 的 GDB 连接到正在运行的进程并在本地调试     |

## 远程选项：项目级设置

Procedure: Gateway 与本地源远程的对比

|  |    通过网关远程连接    |    远程与本地源    |
| --- | --- | --- |
|    项目格式    |  CMake / 编译数据库 / Makefile / Meson  |  CMake / Makefile / Meson  |
|    工具链    |  系统工具链  |  [远程工具链](remote-projects-support.html#remote-toolchain)  |
|    路径映射    |  不需要  |     自动创建，       可在 [部署条目](remote-projects-support.html#deployment-entry) 中自定义     |

Procedure: WSL2 和 Docker

|  |    WSL2    |    Docker    |
| --- | --- | --- |
|    项目格式    |  CMake / 编译数据库 / Makefile / Meson  |  CMake / Makefile / Meson  |
|    工具链    |  WSL  |  Docker  |
|    路径映射    |  不需要  |  可在 [容器设置](clion-toolchains-in-docker.html#create-docker-toolchain) 中配置  |

Procedure: 远程调试

|  |    远程调试    |    远程 GDB 服务器    |
| --- | --- | --- |
|    项目格式    |  任意  |  CMake  |
|    工具链    |  未指定  |     macOS/Linux 上默认；       Windows 上的 MinGW、Cygwin、WSL；       也可用远程和 Docker 工具链     |
|    路径映射    |     未自动创建，       需要在 [运行/调试配置](remote-debug.html#remote-config) 中设置     |     未自动创建，       需要在 [运行/调试配置](remote-gdb-server.html#remote-config) 中设置     |

## See also

### 操作指南

[快速 CMake 教程](quick-cmake-tutorial.html) [Makefile 项目](makefiles-support.html) [Meson 项目](meson.html) [编译数据库](compilation-database.html)

### 概念

[工具链](how-to-create-toolchain-in-clion.html) [运行/调试配置](run-debug-configuration.html)

### 快速开始

[Quick Tutorial: Configure CLion on Windows](quick-tutorial-on-configuring-clion-on-windows.html) [教程：在 macOS 上配置 CLion](quick-tutorial-on-configuring-clion-on-macos.html) [Working with WSL in CLion](how-to-use-wsl-development-environment-in-product.html) [Docker toolchain in CLion](clion-toolchains-in-docker.html)

