Thrift入門之mac下的安裝流程


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

<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模式進入到解壓文件夾的根目錄。

執行命令

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

如果出現missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun錯誤,
先執行

xcode-select --install

安裝thrift的工具依賴libevent庫

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

下載之后解壓,然后用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版本即可


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM