- 打开VSCode
- 将工程根目录拖到vscode中(打开)
- shift+command+p打开命令框
- 输入Tasks:configure task
- 选择others
- 这时会自动打开一个tasks.json文件,并且工程根目录下有一个.vscode目录
- 编辑tasks.json文件如下
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build and run",
"type": "shell",
"command": "g++ -o ${workspaceRoot}/your_program_name ${workspaceRoot}/your_file_name.cpp;${workspaceRoot}/your_program_name",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
command+S保存
shift+command+b编译运行
本文介绍如何在VSCode中配置C++项目的编译和运行环境,通过简单的步骤实现代码的一键编译和执行。
1万+

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



