Thrift入門之mac下的安裝流程

新建一個maven項目,先下載maven依賴  http://thrift.apache.org/downloadhtml

<dependency>
  <groupId>org.apache.thrift</groupId>
  <artifactId>libthrift</artifactId>
  <version>0.11.0</version>
</dependency>

 

再安裝須要的工具  http://thrift.apache.org/docs/install/os_xjava

個人是MacBook Pro,按照要求,git

安裝thrift的工具依賴boost庫github

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

下載以後解壓,而後用cmd模式進入到解壓文件夾的根目錄。bootstrap

執行命令xcode

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

若是出現missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun錯誤,
先執行ruby

xcode-select --install

安裝thrift的工具依賴libevent庫bash

下載地址:http://libevent.org,找一個穩定版本下載,curl

下載以後解壓,而後用cmd模式進入到解壓文件夾的根目錄。

執行命令:

./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:

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

 

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

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
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版本便可

相關文章
相關標籤/搜索