在Linux系统下使用VS Code编写调试C++代码的配置流程
记录一下在linux系统中使用vscode编写调试C++代码的配置过程。
1.随意编写运行代码
首先打开VSCode,创建一个工作区,建立一个cpp文件。这里用helloworld来举例。
#include <iostream>
using namespace std;
int main()
{
cout << "hello world" << endl;
return 0;
}
2.配置task.json
编写完成代码后,用ctrl+shift+P
调出命令行,选择Tasks:Configure Task
即配置任务,然后选择使用模板生成task.json
,然后任务模板选择Others
,此时自动生成task.json。将task.json中的内容替换为:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build", //在launch.json文件中有用到
"type": "shell",
"command": "g++"