怎样让vscode一键编译运行c++并且还能调试

2024-12-14 14:39:47
推荐回答(2个)
回答1:

不知道题主的vscode用的爽不,我正好搜到你的,然后我解决了。一键直接编译调试,断点
vscode配置C/C++的编译调试环境

安装debug插件,然后配置如下,详情参考上面链接
//launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "gdb",
"request": "launch",
"target": "${file}.o",
"cwd": "${workspaceRoot}",
"preLaunchTask": "gcc"
}
]
}

//tasks.json
{
"version": "0.1.0",
"command": "gcc",
"args": ["-g", "${file}", "-o", "${file}.o"],
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}

回答2:

不知道题主的vscode用的爽不,我正好搜到你的,然后我解决了。一键直接编译调试,断点 vscode配置C/C++的编译调试环境 安装debug插件,然后配置如下,详情参考上面链接 //launch.json { "version": "0.2.0", "configurations":