mac vscode配置c/c++环境
时间: 2023-10-22 10:07:21 浏览: 128
你可以按照以下步骤来配置C/C++开发环境:
1. 首先,确保你已经安装了Xcode命令行工具。打开终端并输入以下命令来安装:
```
xcode-select --install
```
2. 然后,安装Homebrew,一个macOS上的包管理器。在终端运行以下命令来安装Homebrew:
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
3. 接下来,使用Homebrew来安装GCC编译器。在终端运行以下命令:
```
brew install gcc
```
4. 然后,安装Visual Studio Code。你可以在官方网站上下载并安装它:[https://code.visualstudio.com/](https://code.visualstudio.com/)
5. 打开Visual Studio Code,在扩展商店中搜索并安装"Code Runner"插件。这个插件可以用来直接在编辑器中运行C/C++代码。
6. 在Visual Studio Code中,按下`Command + Shift + P`(或者`Ctrl + Shift + P`),然后输入并选择"Preferences: Open Settings (JSON)"。
7. 在配置文件中添加以下设置:
```json
"code-runner.executorMap": {
"c": "gcc -std=c11 $fullFileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt"
}
```
8. 保存配置文件,并重新启动Visual Studio Code。
现在,你的mac上已经配置好了C/C++开发环境。你可以创建一个新的C或C++文件,并使用"Code Runner"插件来编译和运行你的代码。
阅读全文
相关推荐















