用mingw配置VScode c++环境
时间: 2024-05-02 22:11:13 浏览: 8
以下是在 Windows 平台上使用 VS Code 和 MinGW 搭建 C++ 开发环境的步骤:
1. 安装 VS Code,下载地址:https://code.visualstudio.com/Download
2. 安装 MinGW,下载地址:http://www.mingw.org/wiki/getting_started
3. 打开 VS Code,在扩展商店搜索并安装 C/C++ 扩展。
4. 打开 VS Code 的用户设置(File -> Preferences -> Settings),搜索“C++”。
5. 找到“C++: Edit Configurations (UI)”选项,点击“Edit in settings.json”按钮,在打开的 settings.json 文件中添加以下配置:
```
{
"configurations": [
{
"name": "MinGW",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "C:/MinGW/bin/g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
```
6. 将上述配置中的 `compilerPath` 改为你的 MinGW 安装路径下的 g++.exe 路径。
7. 在 VS Code 中打开一个 C++ 项目,可以使用 Ctrl+Shift+B 快捷键编译和运行代码。
注意:以上步骤中的路径和配置信息需要根据实际情况进行修改。