一、安装需要的依赖文件
sudo apt install build-essential gdb
查看版本号(安装成功后运行命令会显示对应的版本号)
gcc --version
g++ --version
gdb --version
二、安装cmake
sudo apt install cmake
cmake --version
三:安装插件
点击左边侧边栏四个小方块,在搜索框中依次搜索并安装以下插件:
C/C++
CMake
CMake Tools
四:启动第一个程序:
1.切换到桌面:cd Desktop/
2.建立cpp1文件夹:mkdir cpp1
3.vscode打开文件夹:code ./cpp1
4.创建.cpp文件
File ---> New File创建第一个文件hello.cpp
#include <iostream>
#include <string>
int main(int argc, char const *argv[])
{
std::cout << "hello world!" << std::endl;
return 0;
}
5.创建launch.json 和tasks.json
点击:creat a lunch.json file
选择:C++(GDB/LLDB)
选择:g++ build an activate file
生成两个配置文件
进入到hello.cpp直接按F5或者点击Run -->Start Debugging,
运行成功!