Linux
环境下,使用VS Code
编译C++
工程
1. 准备
-
安装
VS Code
-
安装
g++
(gcc
)编译器
sudo apt-get install g++
或者更新
sudo apt-get update
- 安装
gdb
调试器
sudo apt-get install build-essential gdb
2. 创建Hello World
VS Code
需要为工程配置3个文件:
`tasks.json` :编译器配置
`launch.json`:调试器配置
`c_cpp_properties.json` (编译器路径、智能提示)
- 创建
Hello World
工程
mkdir hello_world
cd hello_world
code .
- 新建
hello_world.cpp
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<string> msg {
"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
for (