mac电脑c环境搭建及brew 1分钟版本
安装xcode
1.安装Xcode
2.命令行输入 xcode-select –install
3.验证安装 clang –version
安装vscode :
官网:https://code.visualstudio.com/
配置插件:
- c++
- code Runner
1 2 3 4 5 6
| #include <stdio.h> int main(){ char a[] ="hello world"; printf("%s", a); return 0; }
|
运行hello world 代码 —-还是Mac 香啊~
brew安装:
brew 简介
使用 brew 安装的软件,其安装位置和配置文件都存放在固定的目录
安装位置: /opt/homebrew/Cellar
配置文件: /opt/homebrew/etc
官网:https://brew.sh/index.html
官网安装命令(要翻墙)
1
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
国内版:一件安装脚本:
教学链接:https://www.cnblogs.com/tommymarc/p/16595592.html
1
| /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
|
常用命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| brew -v 查看当前 homebrew 版本号 brew list 列出已安装的软件 brew search 关键字 根据关键字查找可安装的软件 brew outdated 查看可更新的软件 brew info softwareName 查看某个软件的详细信息 brew upgrade softwareName 升级某个软件的详细信息 brew install、brew uninstall brew install redis brew install nginx brew install php@7.2 // 卸载通过brew install安装的软件 brew uninstall redis brew serivces 命令 brew serivces 命令是专门用来管理通过 homebrew 安装的各类服务的 // 查看所有服务及它们各自的运行状态 brew services list // 启动服务 brew services start redis // 停止服务 brew services stop redis // 重启服务 brew services restart redis
阿里云镜像配置 (zsh 终端) # 替换brew.git: cd "$(brew --repo)" git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git # 替换homebrew-core.git: cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git # 应用生效 brew update # 替换homebrew-bottles: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc source ~/.zshrc
|