0
点赞
收藏
分享

微信扫一扫

mac(10.12.6)安装thritf-0.9.2、protobuf3

一、安装thrift:

最简单的方式是通过brew直接安装:

$brew install thrift@0.9

这样会自动把:boost、openssl、libevent等依赖安装。

可以通过brew来安装thrift,但是安装过程中报错:

mac(10.12.6)安装thritf-0.9.2、protobuf3_eclipse

接下来采用源码编译的方式,在官网下载对应版本的thrift:​​Release 0.9.2 · apache/thrift · GitHub​​

下载后,解压,然后执行:

cd ./thrift-0.9.2
./bootstrap.sh

./configure --prefix=/usr/local/thrift-0.9.2 --disable-static --with-boost=/usr/local --with-libevent=/usr/local --without-python --without-csharp --without-ruby --without-perl --without-php --without-haskell --without-erlang LDFLAGS='-L/usr/local/opt/openssl/lib' CPPFLAGS='-I/usr/local/opt/openssl/include' CXXFLAGS="-std=c++11"

make

make install

执行configure过程中可能会遇到如下错误:

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

升级bison即可:(mac默认自带的是bison2.3)

brew install bison

#环境变量
export PATH=/usr/local/Cellar/bison/3.7.6/bin:$PATH

$ bison -V
bison (GNU Bison) 3.7.6

最后编译成功后,将thrift添加到环境变量:

export PATH=/usr/local/thrift-0.9.2/bin:$PATH

#查看
$ thrift --version
Thrift version 0.9.2

问题:在eclipse中,使用maven的ant插件,执行thrift命令,会报如下错误:

An Ant BuildException has occured: Execute failed: java.io.IOException: Cannot run program "thrift": error=2, No such file or directory

原因:由在 Eclipse 中运行,因此考虑的 $PATH 也已设置为 Eclipse 本身。 Eclipse 通常从桌面图标启动,然后是“桌面”的环境,系统已启动桌面,而不是您可能已更改默认 $PATH 的 bash 提示符。解决方法:

  • use an absolute path to the thrift tool
  • I don't know the Maven launcher in Eclipse, but maybe you can alter the PATH environment variable there
  • make a symbolic link from /usr/bin:sudo ln -s /the/full/path/of/thrift /usr/bin/thrift

​​macos - Execute Thrift from ant within pom.xml - Stack Overflow​​

二、安装protobuf:

和thrift不太一样,在protobuf的github中,已经有编译好的二进制文件,我们直接下载对应的版本即可,例如:​​Release Protocol Buffers v3.15.5 · protocolbuffers/protobuf · GitHub​​

找到protoc-3.15.5-osx-x86_64.zip 下载,解压,然后将其添加到环境变量中:

export PATH=/usr/local/protoc-3.15.5-osx-x86_64/bin:$PATH

查看:

$ protoc --version
libprotoc 3.15.5


举报

相关推荐

0 条评论