由于thrift0.9.2这个版本已经很老了,编译安装问题多多,下面以Debian为例进行说明。我这里的环境是Debian9。
首先这个版本的thrift不能用高版本的go,我实测go1.9.0可以进行编译。当然,GOROOT
和PATH
要设置成go1.9.0的路径,例如:
export GOROOT=/mnt/d/work/library/go1.9.0
export PATH=$GOROOT/bin:$PATH
接着,下载wget https://archive.apache.org/dist/thrift/0.9.2/thrift-0.9.2.tar.gz
。
由于go的mock项目地址更改,我们需要替换一下,注意必须在解压源码之后就先替换:
sed -i "s/code.google.com\/p\/gomock/github.com\/golang\/mock/g" `grep -rl "code.google.com/p/gomock" ./`
需要安装一些库:
sudo apt install build-essential bison flex libevent-dev libssl1.0-dev libtool pkg-config libboost-atomic-dev libboost-chrono-dev libboost-context-dev libboost-coroutine-dev libboost-date-time-dev libboost-dev libboost-exception-dev libboost-filesystem-dev libboost-graph-dev libboost-graph-parallel-dev libboost-iostreams-dev libboost-locale-dev libboost-log-dev libboost-math-dev libboost-program-options-dev libboost-python-dev libboost-random-dev libboost-regex-dev libboost-serialization-dev libboost-signals-dev libboost-system-dev libboost-test-dev libboost-thread-dev libboost-timer-dev libboost-tools-dev libboost-wave-dev liblua5.2-0 libruby libtcl8.6
注意,libssl的版本必须<1.0.2,在Debian8下直接sudo apt install libssl-dev
即可安装libssl1.0.0,Debian9必须sudo apt install libssl1.0-dev
。否则会在configure的时候报错configure: error: "Error: libcrypto required."
然后由于虽然我们装了dev的库,但实际上.so还是1.0.2,在新版本中,SSLv3的部分内容不能用了。所以我们要改lib/cpp/src/thrift/transport/TSSLSocket.cpp
的146行,SSLv3_method
改成SSLv23_method
。(参考)
然后make && sudo make install
即可。注意不能make -j
,因为这库的autoconf写得有问题,并行编译会出问题;而且check写得也有问题,不能make check
。
Comments
注:如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理。