版本:thrift-0.13.0
安装成功的机器:
CentOS Linux release 7.4.1708 (Core)
安装失败的机器:
MacBook Pro
MacOS High Sierra
Version 10.13.6 (17G10021) 2.9 GHz Intel Core i5
想着用php调用HBase, 查了不少教程都是关于thrift的。所以安装一下
http://archive.apache.org/dist/thrift/
2019年10月的最新版本为thrift-0.13.0
./configure
configure: error: Bison version 2.5 or higher must be installed on the system!
bison -V
bison (GNU Bison) 2.3
bison 升级
http://robupcraft.com/install-bison-mac/
下载了个bison-3.5.tar.gz
解压缩
./configure
make
cd src
./bison -V
bison (GNU Bison) 3.5
Written by Robert Corbett and Richard Stallman.
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
下载以后我whereis bison
显示 usr/bin
我想覆盖这个文件,先移动走
mv /usr/bin/bison /usr/bin/bison2.3
mv: rename /usr/bin/bison to /usr/bin/bison2.3: Operation not permitted
最后说mac电脑,锁定了这危险的操作。 我的电脑重要的资料太多怕搞坏了。
找个linux来服务器编译,然后下载来
checking whether g++ supports C++11 features with -h std=c++0x... no
报错
安装C++ 依赖的包
yum -y install libevent-devel zlib-devel openssl-devel
安装C++
yum install gcc gcc-c++ bzip2 bzip2-devel bzip2-libs python-devel -y
(算我无知,这么多年才知道C++也能在Linux下跑,我老以为是windows的专属)
./configure
make
make install
make[4]: composer: Command not found
安装composer
1、下载composer.phar
curl -sS https://getcomposer.org/installer | php
2、把composer.phar移动到环境下让其变成可执行
mv composer.phar /usr/local/bin/composer
3、换中国镜像
composer config -g repo.packagist composer https://packagist.phpcomposer.com
make[3]: *** [gopath] Error 1
make[3]: Leaving directory `/root/thrift-0.13.0/test/go'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/root/thrift-0.13.0/test'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/thrift-0.13.0'
go 出错了
GOROOT目录一般在/usr/lib/golang,我们手动安装在这下面就可以了。在/usr/lib/golang/src(不了解为什么加了个src请先了解一下GOLANG)下面创建目录 github.com/golang/mock/gomock
下载 mock-master.zip 下载地址https://codeload.github.com/golang/mock/zip/master
下载net-master.zip 下载地址 https://codeload.github.com/golang/net/zip/master
将这两个文件放到服务器上。
unzip net-master.zip
mkdir -p /usr/lib/golang/src/golang.org/x/net/
cp -r net-master/* /usr/lib/golang/src/golang.org/x/net/
go install net
unzip mock-master.zip
mkdir -p /usr/lib/golang/src/github.com/golang/mock
cp -r mock-master/* /usr/lib/golang/src/github.com/golang/mock/
go install github.com/golang/mock/gomock
把这两个弄好之后再去刚才那个thrift目录下面执行make 和make install应该就没问题了。
验证一下
thrift -version
Thrift version 0.13.0
完成了
附录
安装之余了解下thrift (http://thrift.apache.org/)
The Apache Thrift software framework, for scalable cross-language services development, combines a software stack with a code generation engine to build services that work efficiently and seamlessly between C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, OCaml and Delphi and other languages.
翻译下
Apache的Thrift 用来跨平台连接C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, OCaml 和 Delphi 和 其他语言。 就是一个超级中介啊。谁经过我,都可以干活了。