1、下载安装vscode
vscode下载地址
2、安装插件

3、添加源文件

4、添加配置

修改launch.jason脚本
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++ - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
4、配置任务

添加task.jason脚本
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++ -g main.cpp -o main",
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
ctrl+shift+B 运行任务脚本
5、切换到源文件 按“F5”运行调试
本文介绍了如何在Linux操作系统中安装和配置Visual Studio Code(vscode),包括下载安装、插件安装、添加源文件、编辑配置文件如launch.json和task.json,以及设置和运行调试任务。
2313

被折叠的 条评论
为什么被折叠?



