一、安装thrift

折腾了好久,才把它安装好,测试还不能准确进行,后续再查原因了。

按照官网上的安装教程:http://thrift.apache.org/docs/install/debian

1)首先安装相关工具包:

sudo apt-get install automake bison flex g++ git libboost-all-dev libevent-dev libssl-dev libtool make pkg-config

Ubuntu16.04下安装和编译thrift0.10.0

此时会出现如下错误提示校验码不符合,下载失败:

Ubuntu16.04下安装和编译thrift0.10.0

Ubuntu16.04下安装和编译thrift0.10.0

这种情况是软件源不满足的问题,因此可以按照本人其他文章去添加Canoniacal合作伙伴:https://mp.csdn.net/postedit/80155608,再重新安装所需工具包即可:

Ubuntu16.04下安装和编译thrift0.10.0

2)安装automake工具包和boost工具包(其中boost是为了支持C++的库(library)和测试(test)):

wget http://ftp.debian.org/debian/pool/main/a/automake-1.15/automake_1.15.1-3.1_all.deb
sudo dpkg -i automake_1.15.1-3.1_all.deb

Ubuntu16.04下安装和编译thrift0.10.0

wget http://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.gz                                                                      tar xvf boost_1_60_0.tar.gz
cd boost_1_60_0
./bootstrap.sh
sudo ./b2 install

Ubuntu16.04下安装和编译thrift0.10.0

3)安装thrift

首先下载需要的thrift版本,本文中使用的是thrift0.10.0,网址为:http://archive.apache.org/dist/thrift/0.10.0/

解压thrift软件包:sudo tar xzvf thrift-0.10.0.tar.gz

Ubuntu16.04下安装和编译thrift0.10.0

进入thrift的根目录,进行编译配置,在进行编译配置的时候需要显示指明boost的位置,如果未指明只是简单的执行./configure,编译配置是不会有错误,但在执行make时会有“recipe for target xxx failed”,此时执行的命令如下:

./connfigure

make

如下错误:

Ubuntu16.04下安装和编译thrift0.10.0

Ubuntu16.04下安装和编译thrift0.10.0

又看了一遍thrift中的README文件,其中有这样一句:

Ubuntu16.04下安装和编译thrift0.10.0

不太明白什麼意思,但还是改了下配置编译的命令试一下,结果make时没有报这种错误了,此时执行的命令如下:

./configure --with-boost=/usr/boost

make

Ubuntu16.04下安装和编译thrift0.10.0

Ubuntu16.04下安装和编译thrift0.10.0

Ubuntu16.04下安装和编译thrift0.10.0

但是中间有报错缺少python头文件,这是python的版本不对,需要安装python3,执行如下命令https://blog.csdn.net/sjz_hahalala479/article/details/73323574?fps=1&locationNum=8点击打开链接

sudo apt-get install python3-dev

Ubuntu16.04下安装和编译thrift0.10.0

安装完成之后执行:

make

sudo make install

Ubuntu16.04下安装和编译thrift0.10.0

Ubuntu16.04下安装和编译thrift0.10.0

4)执行命令:thrift -version看是否安装成功

此时报错thrift: error while loading shared libraries: libthriftc.so.0: cannot open shared object file: No such file or directory,如下图:

Ubuntu16.04下安装和编译thrift0.10.0

参考如下两篇文章:

http://www.linuxdiyf.com/linux/27018.html点击打开链接

http://www.linuxdiyf.com/linux/18254.html点击打开链接

通过ls /usr/local/lib命令,发现 libthriftc.so.0存在:

Ubuntu16.04下安装和编译thrift0.10.0

因此要把次共享库目录添加到共享库配置文件/etc/ld.so.conf中,执行过程如下图:

Ubuntu16.04下安装和编译thrift0.10.0

由于权限问题,输入过程中犯了点小错误,至此,thrift安装已经完成,但是在测试时还有点儿小问题,不能生成cppclient和cppserver文件,后续在查原因了。

错误参考链接:https://stackoverflow.com/questions/37268341/thrift-0-9-3-package-c-build-issues-which-boost-packages-to-use#点击打开链接

相关文章:

  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
  • 2021-09-13
  • 2021-08-29
  • 2021-10-31
  • 2022-01-25
  • 2021-05-28
猜你喜欢
  • 2021-10-13
  • 2022-12-23
  • 2021-09-17
  • 2021-06-30
  • 2021-11-12
  • 2021-06-05
  • 2021-07-15
相关资源
相似解决方案