Ubuntu vscode配置c/c++环境
时间: 2023-11-05 22:59:52 浏览: 188
要在Ubuntu上配置VSCode的C/C++环境,你需要按照以下步骤进行操作:
1. 首先,安装gcc和g++,你可以使用以下命令进行安装:
```
sudo apt install gcc g++
```
2. 在VSCode商店中安装C/C++扩展插件。
3. 在工作区中创建一个launch.json文件并添加以下配置:
```
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"preLaunchTask": "build",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
```
4. 创建一个tasks.json文件并添加以下配置:
```
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": [
"-g",
"${file}",
"-std=c++11",
"-o",
"${fileBasenameNoExtension}.out"
],
"problemMatcher": []
}
]
}
```
5. 现在你可以运行测试文件了。
阅读全文
相关推荐
















