实践篇:Install Homebrew and Boost Library 以及 Xcode配置Boost库


为什么写这篇文章?
1.在安装Homebrew的时候,我去网上找过相关资料,不过都是千篇一律,都是copy来copy去的。我按照了其中几篇博文的方法,却出现了莫名其妙的问题。于是,我写了这篇文章,来帮助与我遇到同样问题的童鞋!
2.在安装boost后,xcode的配置boost库是个大问题,网上没有较为详细教程。


1.Homebrew

“Homebrew installs the stuff you need that Apple didn’t.”——Homebrew

Homebrew作为OS X上强大的包管理器,为系统软件提供了非常方便的安装方式,独特式的解决了包的依赖问题,并不再需要烦人的sudo,一键式编译,无参数困扰。 —@李惟

安装方法:
我强烈推荐上Homebrew官网去下载,网上博客给出的链接:一是不安全,二是不稳定,可能会导致homebrew装偏(我遇到的问题)。

(以下内容截至本人终端,内容可能会因机而异, 但指令一般都是一样的)

用ruby指令安装,一般OS X自带ruby:

  ~ ruby --version
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

将下面的指令复制到终端运行:

// 链接1
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

// 链接2
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)

正常情况下是能够安装成功的,用brew语句安装你想安装的东西试试,是否能正常运行:
举个例子, 我下载boost库。

➜  cd /usr/locallocal brew install boost

如果正常的话,应当是:

➜  local brew install boost       
==> Downloading https://homebrew.bintray.com/bottles/boost-1.60.0_2.yosemite.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring boost-1.60.0_2.yosemite.bottle.1.tar.gz
/usr/local/Cellar/boost/1.60.0_2: 11,139 files, 436.8M

如果不正常,会出现下面的情况:

local brew install boost
fatal: could not create leading directories of '/usr/local/Library/Taps/homebrew/homebrew-core': Permission denied
Error: Failure while executing: git clone https://github.com/Homebrew/homebrew-core /usr/local/Library/Taps/homebrew/homebrew-core --config core.autocrlf=false --depth=1 -q
Error: Failure while executing: /usr/local/bin/brew tap homebrew/core -q

说明你的homebrew装偏了,具体原因我也说不出来,反正就是装失败了,这种情况下该怎么解决呢?

Of course, 进行修复:
在终端中输入下列语句:

local sudo chown -R apple:staff *
➜  local brew doctor

然后就出现:

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!


Warning: Python is installed at /Library/Frameworks/Python.framework

Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.

... // 这部分内容不同电脑是不同的

待指令执行结束,homebrew也就修复好了,试着安装你想安装的软件吧~

检测homebrew是否安装:

➜  ~ cd /usr/locallocal ls
CODEOFCONDUCT.md LICENSE.txt      README.md        homebrew         lib              share
Cellar           Library          bin              include          opt

找到homebrew说明安装成功。

homebrew 常用操作:

brew install xxx ——安装xxx
brew uninstall xxx ——卸载xxx

  • 6
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值