Mac下安装Thrift 以及问题解决

今天遇到 thrift 的需求,因而安装了一下 Apache 的 Thrift,发现安装过程很艰辛,把遇到的坑整理一下,让大家减小浪费一些时间php

常规方法

使用brew安装Thrifthtml

brew install thrift

可是这个方法只能安装 brew 中存在的版本,当前只有最新版 0.12.0 和 0.9.0 这两个版本,若是想安装其余版本,仍是要经过官网方法安装java

官网方法

首先,下载源码,能够经过 官网文件列表 查找对应版本;若是官网较慢,也能够经过 镜像网站 来查找node

而后解压,进入目录,执行以下命令便可python

./configure && make

当安装完成后,可使用以下命令,来检测是否安装好了apache

thrift --version

问题 · 解决

首先是安装依赖问题,若是遇到像:npm

Bison version 2.5 or higher must be installed on the system!

这样的报错,能够用以下方法(参考自 mac安装thrift ):ruby

brew install bison

# 注意这里改为本身的路径
# 这是一个临时的环境变量,关闭终端会失效
PATH="/usr/local/Cellar/bison/3.0.4_1/bin/:$PATH"

网上还会搜到其余的方法,也能够参考 Mac安装thrift因bison报错的解决办法 。可是感受仍是上面的方法更简单工具

若是遇到这样的报错:post

src/thrift/transport/TSSLSocket.cpp:43:10: fatal error: 'openssl/opensslv.h' file not found

可使用以下方法,参考自 Dive Into Thrift Node-安装

brew install openssl # 若是已安装,则进行下一步
brew install pkg-config # 若是已安装,则进行下一步

brew link openssl --force
# 执行此命令,系统会提示有多个方法能够选择,咱们能够选 pkg-config 的方法
# 即执行 export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"

pkg-config 的介绍 理解 Linux中的pkg-config 工具

以后执行官网安装步骤:

由于 Thrift 支持多种语言,但咱们通常只须要一种语言就够了,因此咱们能够把其余语言都不选,避免由于其余语言的各类问题带来报错:

./configure LDFLAGS='-L/usr/local/opt/openssl/lib' CPPFLAGS='-I/usr/local/opt/openssl/include' --with-nodejs=yes --with-qt4=no --with-qt5=no --with-openssl=DIR --with-csharp=no --with-c_glib=no --with-java=no --with-erlang=no --with-lua=no --with-python=no --with-perl=no --with-php=no --with-php_extension=no --with-dart=no --with-ruby=no --with-haskell=no --with-go=no --with-rs=no --with-haxe=no --with-dotnetcore=no --with-d=no

若是成功了,就执行:

make

不要执行sudo命令,不然会致使npm的内部报错

以后没有报错的话应该就安装成功了

相关文章
相关标签/搜索