vs2026远程调试linux
网上都搜索不到有关教程,自己摸索了一下。
vs2026的安装步骤直接跳过,创建项目时选择cmake的项目

在Linux系统中,如果是使用yum的包管理(比如centos),下载一些软件,远程调试需要使用
sudo yum install -y openssh-server gcc-c++ gdb gdb-gdbserver make ninja-build rsync zip unzip
然后在vs中的工具栏处选择“管理连接”

将自己需要连接的Linux系统添加到其中,输入ip地址也可以:

等编码好项目源码,确保这些配置正确:

尤其是调试目标:

然后点击调试目标的绿色小箭头即可~
附录,CMakePresets.json内容(默认的):
{ "version": 3, "configurePresets": [ { "name": "windows-base", "hidden": true, "generator": "Ninja", "binaryDir": "${sourceDir}/out/build/${presetName}", "installDir": "${sourceDir}/out/install/${presetName}", "cacheVariables": { "CMAKE_C_COMPILER": "cl.exe", "CMAKE_CXX_COMPILER": "cl.exe" }, "condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Windows" } }, { "name": "x64-debug", "displayName": "x64 Debug", "inherits": "windows-base", "architecture": { "value": "x64", "strategy": "external" }, "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } }, { "name": "x64-release", "displayName": "x64 Release", "inherits": "x64-debug", "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } }, { "name": "x86-debug", "displayName": "x86 Debug", "inherits": "windows-base", "architecture": { "value": "x86", "strategy": "external" }, "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } }, { "name": "x86-release", "displayName": "x86 Release", "inherits": "x86-debug", "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } }, { "name": "linux-debug", "displayName": "Linux Debug", "generator": "Ninja", "binaryDir": "${sourceDir}/out/build/${presetName}", "installDir": "${sourceDir}/out/install/${presetName}", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" }, "condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Linux" }, "vendor": { "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}" } } }, { "name": "macos-debug", "displayName": "macOS Debug", "generator": "Ninja", "binaryDir": "${sourceDir}/out/build/${presetName}", "installDir": "${sourceDir}/out/install/${presetName}", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" }, "condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Darwin" }, "vendor": { "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}" } } } ] }
浙公网安备 33010602011771号