1. vscode下载
去vscode官网下载.deb版本的
vscode官网
随后cd到对应的目录(下载文件的目录),然后
sudo dpkg -i code_1.31.1-1549938243_amd64.deb
dpkg对应的文件
具体的可以看这个链接
2.下载对应的插件
创建文件夹
- 新建空文件夹
- 用vscode打开对应文件夹并创建测试cpp文件
在.vscode文件夹里面创建launch.json 和 task.json
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"preLaunchTask": "build",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
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",
"type": "shell",
"command": "g++",
"args": ["-g", "${file}", "-std=c++11", "-o", "${fileBasenameNoExtension}.out"]
}
]
}
修改settings.json
按crtl + shift + p ,选择首选项:打开设置(json)
查询你自己的g++库在哪里
查看g++的includePath,并去Settings,json去修改。
g++ -v -E -x c++ -
修改对应的位置
修改cpp执行命令
将把g++后面的filename 改为 &
*.cpp
这样的话才能执行文件中的所有cpp文件,避免出现多个文件无法编译情况。