macos gcc 安装

参考文章:https://wangxin1248.github.io/life/2019/06/mac-update-gcc.html

mac 编译 ollvm 失败,可能原因是 gcc 版本太高

brew search gcc
brew install gcc@8

gcc-8 --version

homebrew 卡着的问题,替换源,参考 : https://www.jianshu.com/p/cd88d9d70705

cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

#替换homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
brew update


# 备用地址-1
cd "$(brew --repo)"
git remote set-url origin https://git.coding.net/homebrew/homebrew.git
brew update


# 备用地址-2
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew-core.git
brew update
如果备用地址都不行,那就只能再换回官方地址了


#重置brew.git
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

#重置homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git

发现用家庭带宽,下载速度贼慢,用了 移动 流量,下载速度贼快;

设置环境变量,参考 : https://my.oschina.net/u/4408992/blog/4245798

编辑~/.zshrc,在最后加上如下代码

alias gcc="gcc-8"
alias g++="g++-8"
alias cc="gcc-8"
alias c++="c++-8"

你可能感兴趣的:(macos gcc 安装)