Ubuntu C++远程开发主要通过VS Code的Remote - SSH插件实现,步骤如下:
配置远程服务器SSH
sudo apt update && sudo apt install openssh-server。sudo systemctl start ssh && sudo systemctl enable ssh。~/.ssh/authorized_keys。本地VS Code配置
user@host(如ubuntu@192.168.1.100),按提示完成连接。远程开发环境搭建
sudo apt install build-essential gdb。.cpp文件,编写代码后保存。编译与调试
g++ -o output source.cpp。launch.json:在.vscode目录下创建或编辑该文件,设置"type": "cppdbg",指定程序路径和调试器参数(如"program": "${workspaceFolder}/output")。说明:若需远程调试,需在目标服务器安装gdbserver,并通过target remote命令连接本地GDB。以上步骤基于VS Code远程开发,适用于跨平台C++项目开发场景。