Mac 安装thrift 0.8.0 亲身实测可用

 

目录

 

开发环境除了需要安装thrift,还需要安装maven等,所以直接使用Homebrew 进行安装,可能是因为我比较懒,不想下那么多包吧。

1.安装brew

brew官网地址:https://brew.sh/index_zh-cn.html。官网上有安装命令,据说会更新,可以从官网上复制命令,见下图。

'

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew的安装很简单,只需在终端下输入如下指令:

安装成功后,会自动创建目录 /usr/local/Cellar 来存放Homebrew安装的程序。 这时你在命令行状态下面就可以使用 brew 命令了。

 

2.安装thrift依赖环境

日常包安装流程:安装boost -> 安装libevent -> 安装thrift 。

此时我们简化:brew安装thrift -> 卸载thrift。完成依赖环境安装。

//1.安装thrift,默认是最高版本
$  brew install thrift
//2.安装成功后再卸载,保留依赖环境
$  brew uninstall thrift
//3.查看当前安装软件
$  brew list
//4.由于默认将openssl安装到/usr/local/opt/openssl目录,不在默认的系统目录,导致编译libevent时仍不能找到openssl,故通过ln命令在系统目录建立openssl相关的软连接从而编译libevent时方便找到openssl。否则编译报错 fatal error: 'openssl/bio.h' file not found
$ 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

//5.至此依赖环境就安装好了
安装thrift依赖环境,直接命令行输入
  1 sangodeMacBook-Pro:thrift sango$ brew install thrift
  2 ==> Installing dependencies for thrift: icu4c, boost and openssl
  3 ==> Installing thrift dependency: icu4c
  4 ==> Downloading https://homebrew.bintray.com/bottles/icu4c-64.2.mojave.bottle.tar.gz
  5 ==> Downloading from https://akamai.bintray.com/e8/e858556120acc0c2d52b8fb572b677856724cc28d24a7e1b2762d458a2977c8e?__gda__=exp=1562294118~hmac=f7a
  6 ######################################################################## 100.0%
  7 ==> Pouring icu4c-64.2.mojave.bottle.tar.gz
  8 ==> Caveats
  9 icu4c is keg-only, which means it was not symlinked into /usr/local,
 10 because macOS provides libicucore.dylib (but nothing else).
 11 
 12 If you need to have icu4c first in your PATH run:
 13   echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
 14   echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile
 15 
 16 For compilers to find icu4c you may need to set:
 17   export LDFLAGS="-L/usr/local/opt/icu4c/lib"
 18   export CPPFLAGS="-I/usr/local/opt/icu4c/include"
 19 
 20 ==> Summary
 21 🍺  /usr/local/Cellar/icu4c/64.2: 257 files, 69.2MB
 22 ==> Installing thrift dependency: boost
 23 ==> Downloading https://homebrew.bintray.com/bottles/boost-1.70.0.mojave.bottle.tar.gz
 24 ==> Downloading from https://akamai.bintray.com/c6/c626b90770424ca969d0870d25d7fb13cf9d4f23a828407701face0e7ec4ac93?__gda__=exp=1562294170~hmac=18f
 25 ######################################################################## 100.0%
 26 ==> Pouring boost-1.70.0.mojave.bottle.tar.gz
 27 🍺  /usr/local/Cellar/boost/1.70.0: 13,983 files, 521.8MB
 28 ==> Installing thrift dependency: openssl
 29 ==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2s.mojave.bottle.tar.gz
 30 ==> Downloading from https://akamai.bintray.com/c4/c4a762d719c2be74ac686f1aafabb32f3c5d5ff3a98935c4925a1ddb9c750ee1?__gda__=exp=1562294482~hmac=65e
 31 ######################################################################## 100.0%
 32 ==> Pouring openssl-1.0.2s.mojave.bottle.tar.gz
 33 ==> Caveats
 34 A CA file has been bootstrapped using certificates from the SystemRoots
 35 keychain. To add additional certificates (e.g. the certificates added in
 36 the System keychain), place .pem files in
 37   /usr/local/etc/openssl/certs
 38 
 39 and run
 40   /usr/local/opt/openssl/bin/c_rehash
 41 
 42 openssl is keg-only, which means it was not symlinked into /usr/local,
 43 because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
 44 
 45 If you need to have openssl first in your PATH run:
 46   echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
 47 
 48 For compilers to find openssl you may need to set:
 49   export LDFLAGS="-L/usr/local/opt/openssl/lib"
 50   export CPPFLAGS="-I/usr/local/opt/openssl/include"
 51 
 52 ==> Summary
 53 🍺  /usr/local/Cellar/openssl/1.0.2s: 1,795 files, 12.0MB
 54 ==> Installing thrift
 55 ==> Downloading https://homebrew.bintray.com/bottles/thrift-0.12.0.mojave.bottle.tar.gz
 56 ==> Downloading from https://akamai.bintray.com/84/84321af08a88b55fb203083d5653cf2daf7815dbaa3093deb38af952c65e749b?__gda__=exp=1562294527~hmac=917
 57 ########################                                                  34.3%
 58 curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
 59 Error: Failed to download resource "thrift"
 60 Download failed: https://homebrew.bintray.com/bottles/thrift-0.12.0.mojave.bottle.tar.gz
 61 Warning: Bottle installation failed: building from source.
 62 ==> Installing dependencies for thrift: bison
 63 ==> Installing thrift dependency: bison
 64 ==> Downloading https://homebrew.bintray.com/bottles/bison-3.4.1.mojave.bottle.tar.gz
 65 ==> Downloading from https://akamai.bintray.com/96/96565e8ced7e49173e86a6971a71a205814411945d86d599733ab83b2e24afad?__gda__=exp=1562295465~hmac=ce5
 66 ######################################################################## 100.0%
 67 ==> Pouring bison-3.4.1.mojave.bottle.tar.gz
 68 ==> Caveats
 69 bison is keg-only, which means it was not symlinked into /usr/local,
 70 because some formulae require a newer version of bison.
 71 
 72 If you need to have bison first in your PATH run:
 73   echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile
 74 
 75 For compilers to find bison you may need to set:
 76   export LDFLAGS="-L/usr/local/opt/bison/lib"
 77 
 78 ==> Summary
 79 🍺  /usr/local/Cellar/bison/3.4.1: 85 files, 2.6MB
 80 ==> Downloading https://www.apache.org/dyn/closer.cgi?path=/thrift/0.12.0/thrift-0.12.0.tar.gz
 81 ==> Downloading from http://mirrors.tuna.tsinghua.edu.cn/apache/thrift/0.12.0/thrift-0.12.0.tar.gz
 82 ######################################################################## 100.0%
 83 ==> ./configure --disable-tests --prefix=/usr/local/Cellar/thrift/0.12.0 --libdir=/usr/local/Cellar/thrift/0.12.0/lib --with-openssl=/usr/local/opt
 84 ==> make
 85 ==> make install
 86 🍺  /usr/local/Cellar/thrift/0.12.0: 102 files, 6.8MB, built in 4 minutes 42 seconds
 87 Removing: /usr/local/Cellar/thrift/0.8.0... (1,178 files, 10.8MB)
 88 ==> Caveats
 89 ==> icu4c
 90 icu4c is keg-only, which means it was not symlinked into /usr/local,
 91 because macOS provides libicucore.dylib (but nothing else).
 92 
 93 If you need to have icu4c first in your PATH run:
 94   echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
 95   echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile
 96 
 97 For compilers to find icu4c you may need to set:
 98   export LDFLAGS="-L/usr/local/opt/icu4c/lib"
 99   export CPPFLAGS="-I/usr/local/opt/icu4c/include"
100 
101 ==> openssl
102 A CA file has been bootstrapped using certificates from the SystemRoots
103 keychain. To add additional certificates (e.g. the certificates added in
104 the System keychain), place .pem files in
105   /usr/local/etc/openssl/certs
106 
107 and run
108   /usr/local/opt/openssl/bin/c_rehash
109 
110 openssl is keg-only, which means it was not symlinked into /usr/local,
111 because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
112 
113 If you need to have openssl first in your PATH run:
114   echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
115 
116 For compilers to find openssl you may need to set:
117   export LDFLAGS="-L/usr/local/opt/openssl/lib"
118   export CPPFLAGS="-I/usr/local/opt/openssl/include"
119 
120 ==> bison
121 bison is keg-only, which means it was not symlinked into /usr/local,
122 because some formulae require a newer version of bison.
123 
124 If you need to have bison first in your PATH run:
125   echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile
126 
127 For compilers to find bison you may need to set:
128   export LDFLAGS="-L/usr/local/opt/bison/lib"
1.安装thrift,默认是最高版。命令:$ brew install thrift
sangodeMacBook-Pro:thrift sango$ brew uninstall thrift
Uninstalling /usr/local/Cellar/thrift/0.12.0... (102 files, 6.8MB)
2.卸载thrift,命令:$ brew uninstall thrift
1 sangodeMacBook-Pro:Cellar sango$ brew list
2 bison        boost        icu4c        maven@3.3    openssl
3.查看当前安装软件,命令:$ brew list
 1 sangodeMacBook-Pro:local sango$ brew link openssl --force
 2 Warning: Refusing to link macOS-provided software: openssl
 3 If you need to have openssl first in your PATH run:
 4   echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
 5 
 6 For compilers to find openssl you may need to set:
 7   export LDFLAGS="-L/usr/local/opt/openssl/lib"
 8   export CPPFLAGS="-I/usr/local/opt/openssl/include"
 9 sangodeMacBook-Pro:local sango$ ln -s /usr/local/opt/openssl/bin/openssl /usr/local/bin/openssl
10 sangodeMacBook-Pro:local sango$ ln -s /usr/local/opt/openssl/include/openssl /usr/local/include/openssl
11 sangodeMacBook-Pro:local sango$ ln -s /usr/local/opt/openssl/lib/libssl.a /usr/local/lib/libssl.a
12 sangodeMacBook-Pro:local sango$ ln -s /usr/local/opt/openssl/lib/libcrypto.a /usr/local/lib/libcrypto.a
4.建立软连接

 

3.安装thrift0.8.0

下载包:thrift-0.8.0.zip

因为默认安装的版本是thrift0.12.0,不符合我们的要求。还是需要通过包来安装,下载上面的包(包已经修改好了,不需要再去执行命令替换了)。

 1 //1.解压包后,进入包路径,这是我的路径
 2 $ cd /usr/local/Cellar/thrift/0.8.0
 3 
 4 //2.编译命令
 5 $ ./configure --disable-debug --prefix=/usr/local/Cellar/thrift/0.8.0 --libdir=/usr/local/Cellar/thrift/0.8.0/lib \
 6     --without-ruby \
 7     --disable-tests \
 8     --without-php_extension \
 9     --without-python \
10     --without-haskell \
11     --without-perl \
12     --without-php \
13     --without-erlang
14   
15 //3.安装命令
16 $  sudo make install
17  
18 //4.检查版本
19 $ thrift -version 
解压包,进入包目录,执行指令安装
1 sangodeMacBook-Pro:0.8.0 sango$ thrift -version
2 Thrift version 0.8.0
检查版本,安装完成

 

4.遇到的问题

看别人安装一路顺畅,自己安装就错误频出,怎么破?下面有几个我遇到的问题,记录一下,有遇到的可以参考一下。

待补充~~

 

posted @ 2020-10-12 16:06  selicoco  阅读(1135)  评论(0编辑  收藏  举报