Thrift入门之mac下的安装流程

 

 

新建一个maven项目,先下载maven依赖  http://thrift.apache.org/download

1
2
3
4
5
<dependency>
   <groupId>org.apache.thrift</groupId>
   <artifactId>libthrift</artifactId>
   <version> 0.11 . 0 </version>
</dependency>

 

再安装需要的工具  http://thrift.apache.org/docs/install/os_x

我的是MacBook Pro,按照要求,

安装thrift的工具依赖boost库

下载地址:www.boost.org,找到最新的版本下载,

下载之后解压,然后用cmd模式进入到解压文件夹的根目录。

执行命令

1
2
./bootstrap.sh
sudo ./b2 threading=multi address-model= 64  variant=release stage install  

如果出现missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun错误,
先执行

1
xcode-select --install

安装thrift的工具依赖libevent库

下载地址:http://libevent.org,找一个稳定版本下载,

下载之后解压,然后用cmd模式进入到解压文件夹的根目录。

执行命令:

1
2
3
./configure --prefix=/usr/local
make
sudo make install

  

make的时候出现 fatal error: 'openssl/bio.h' file not found

这是由于mac默认安装了openssl但是没有安装对应的include头文件和lib库,故这里使用homebrew(参考https://brew.sh/index_zh-cn.html)来安装最新的openssl

先安装homebrew:

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

再用homebrew安装openssl(xcode要是最新版本的才能安装):

1
2
3
4
5
6
7
8
9
10
11
brew install openssl
 
brew link openssl --froce
 
ln -s /usr/local/opt/openssl/bin/openssl /usr/local/bin/openssl
 
ln -s /usr/local/opt/openssl/include/openssl /usr/local/include/openssl
 
ln -s /usr/local/opt/openssl/lib/libssl.a /usr/local/lib/libssl.a
 
ln -s /usr/local/opt/openssl/lib/libcrypto.a /usr/local/lib/libcrypto.a

 然后重新运行 make  sudo make install 命令来安装libevent 

安装Apache Thrift

下载最新版本的thrift 0.11,下载地址:http://archive.apache.org/dist/thrift/

解压下载的文件,进入该目录,运行以下脚本

./configure --prefix=/usr/local/ --with-boost=/usr/local --with-libevent=/usr/local
1
2
make
sudo make install

如果报错error: Bison version 2.5 or higher must be installed on the system!

解决办法:mac中默认安装了bison 2.3版本,并配置了路径在path中。安装最新的版本3.0.4, 并将/usr/bin中的bison删除,将bison 3.0.4 复制到/usr/bin中
cd /usr/bin
brew install bison
brew unlink bison
source ~/.bash_profile 或者 export PATH=/usr/local/Cellar/bison/3.0.4_1/bin:$PATH
把其加入环境变量
再执行 bison -V , 版本号变成3.0.4即可

 运行thrift -version 命令查看thrift版本即可

作者: lost blog

新建一个maven项目,先下载maven依赖  http://thrift.apache.org/download

1
2
3
4
5
<dependency>
   <groupId>org.apache.thrift</groupId>
   <artifactId>libthrift</artifactId>
   <version> 0.11 . 0 </version>
</dependency>

 

再安装需要的工具  http://thrift.apache.org/docs/install/os_x

我的是MacBook Pro,按照要求,

安装thrift的工具依赖boost库

下载地址:www.boost.org,找到最新的版本下载,

下载之后解压,然后用cmd模式进入到解压文件夹的根目录。

执行命令

1
2
./bootstrap.sh
sudo ./b2 threading=multi address-model= 64  variant=release stage install  

如果出现missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun错误,
先执行

1
xcode-select --install

安装thrift的工具依赖libevent库

下载地址:http://libevent.org,找一个稳定版本下载,

下载之后解压,然后用cmd模式进入到解压文件夹的根目录。

执行命令:

1
2
3
./configure --prefix=/usr/local
make
sudo make install

  

make的时候出现 fatal error: 'openssl/bio.h' file not found

这是由于mac默认安装了openssl但是没有安装对应的include头文件和lib库,故这里使用homebrew(参考https://brew.sh/index_zh-cn.html)来安装最新的openssl

先安装homebrew:

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

再用homebrew安装openssl(xcode要是最新版本的才能安装):

1
2
3
4
5
6
7
8
9
10
11
brew install openssl
 
brew link openssl --froce
 
ln -s /usr/local/opt/openssl/bin/openssl /usr/local/bin/openssl
 
ln -s /usr/local/opt/openssl/include/openssl /usr/local/include/openssl
 
ln -s /usr/local/opt/openssl/lib/libssl.a /usr/local/lib/libssl.a
 
ln -s /usr/local/opt/openssl/lib/libcrypto.a /usr/local/lib/libcrypto.a

 然后重新运行 make  sudo make install 命令来安装libevent 

安装Apache Thrift

下载最新版本的thrift 0.11,下载地址:http://archive.apache.org/dist/thrift/

解压下载的文件,进入该目录,运行以下脚本

./configure --prefix=/usr/local/ --with-boost=/usr/local --with-libevent=/usr/local
1
2
make
sudo make install

如果报错error: Bison version 2.5 or higher must be installed on the system!

解决办法:mac中默认安装了bison 2.3版本,并配置了路径在path中。安装最新的版本3.0.4, 并将/usr/bin中的bison删除,将bison 3.0.4 复制到/usr/bin中
cd /usr/bin
brew install bison
brew unlink bison
source ~/.bash_profile 或者 export PATH=/usr/local/Cellar/bison/3.0.4_1/bin:$PATH
把其加入环境变量
再执行 bison -V , 版本号变成3.0.4即可

 运行thrift -version 命令查看thrift版本即可

猜你喜欢

转载自www.cnblogs.com/xc1234/p/9090274.html