一 VsCode安装
看了很多,小鱼的安装最方便快捷
wget http://fishros.com/install -O fishros && . fishros
终端输入后,一键安装VsCode开发工具
二 VsCode配置
1.扩展包
扩展功能按钮内分别输入“chinese”和“c++”安装中文扩展包和c++扩展包,参考下图:
2.写下第一个“hello world”
1/4 新建一个helloworld.cpp,在文件内写入以下代码:
#include <iostream>
using namespace std;int main(int argc, char **argv)
{
cout << "hello world!" << endl;
return 0;}
2/4 新建一个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",
"miDebuggerArgs": "-q -ex quit; wait() { fg >/dev/null; }; /usr/bin/gdb -q --interpreter=mi",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
3/4 新建一个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",
"type": "shell",
"command": "g++",
"args": ["-g", "${file}", "-std=c++11", "-o", "${fileBasenameNoExtension}.out"]
}
]
}
4/4 最后点击cpp文件,开始运行调试,你第一个在VsCod环境下的helloworld程序生成啦!!