linux下安装c语言支持的thrift库

由于工作需要用到C库的thrift,但是在安装过程中遇到了各种坑,而网上又没有一篇关于C_GLIB的thrift安装指导,我也花了将近两天才搞定,

为了避免别的同学重复造轮子,特输出造轮子秘方,以帮助大家规避各种坑。

在前期环境准备上,有借鉴 郭了个治浩同学的C++环境安装方法 :http://blog..net/mysteryhaohao/article/details/51881274#t7

安装步骤:

Building Apache Thrift with C_GLIB on CentOS 6.5

Apache Thrift configure 1.0.0-dev.

Update the System

sudo yum -y update

Install the Platform Development Tools

sudo yum -y groupinstall "Development Tools"

Upgrade autoconf/automake/bison

sudo yum install -y wget

Upgrade autoconf

wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz

tar xvf autoconf-2.69.tar.gz

cd autoconf-2.69

./configure --prefix=/usr

make

sudo make install

Upgrade automake

wget http://ftp.gnu.org/gnu/automake/automake-1.14.tar.gz

tar xvf automake-1.14.tar.gz

cd automake-1.14

./configure --prefix=/usr

make

sudo make install

Upgrade bison

wget http://ftp.gnu.org/gnu/bison/bison-2.5.1.tar.gz

tar xvf bison-2.5.1.tar.gz

cd bison-2.5.1

./configure --prefix=/usr

make

sudo make install

Install C Lib Dependencies GLIB

下载地址:http://ftp.gnome.org/pub/gnome/sources/glib/2.50/

./configure --with-pcre=internal --enable-libmount=no --prefix=/usr

参数意义:--with-pcre=internal 用内置库pcre,yum install安装的pcre库版本较低

--enable-libmount=no 不需要libmount库,是因为并不是必须,另外我在网上找了很久都没有找到这个库的安装文件,yum install 也没找到。如果有人找到了,请告诉我 谢谢

make && make install

Install thrift

git clone https://git-wip-us.apache.org/repos/asf/thrift.git

cd thrift

./bootstrap.sh

./configure CFLAGS="-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include" LDFLAGS="-lglib-2.0" --with-php=no --prefix=/usr/

thrift 1.0.0-dev

Building Plugin Support ...... : no

Building C++ Library ......... : no

Building C (GLib) Library .... : yes

Building Java Library ........ : no

Building C# Library .......... : no

Building Python Library ...... : yes

Building Ruby Library ........ : no

Building Haxe Library ........ : no

Building Haskell Library ..... : no

Building Perl Library ........ : no

Building PHP Library ......... : no

Building Dart Library ........ : no

Building Erlang Library ...... : no

Building Go Library .......... : yes

Building D Library ........... : no

Building NodeJS Library ...... : no

Building Lua Library ......... : no

Python Library:

Using Python .............. : /usr/bin/python

Go Library:

Using Go................... : /usr/bin/go

Using Go version........... : go version go1.7.3 linux/amd64

If something is missing that you think should be present,

please skim the output of configure to find the missing

component. Details are present in config.log.

这里 要确保你需要的库 Building C (GLib) Library …. : yes 为yes.

为No的意思是,当前环境不具备编译该库的条件。

具体错误详情,可以进入 lib/c_glib目录下面,直接make

看具体是报什么错误,然后根据相应错误来修改

在这个目录make 成功也是可以的

安装

make

sudo make install

验证安装

thrift --version

Thrift version 1.0.0-dev

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐