Thrift介绍
Thrift是一个软件框架,用来进行可扩展且跨语言的服务的开发。它结合了功能强大的软件堆栈和代码生成引擎,以构建在 C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, and OCaml 这些编程语言间无缝结合的、高效的服务。
安装开发工具集
sudo yum -y groupinstall "Development Tools"
安装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
cd ..
安装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
cd ..
安装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
cd ..
安装C++依赖库
sudo yum -y install libevent-devel zlib-devel openssl-devel
安装boost
wget http://iweb.dl.sourceforge.net/project/boost/boost/1.60.0/boost_1_60_0.tar.gz
./bootstrap.sh --prefix=/usr
./b2 install
cd ..
安装libevent
wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
./configure --prefix=/usr
make
sudo make install
cd ..
安装Thrift
git clone https://git-wip-us.apache.org/repos/asf/thrift.git
cd thrift
./configure --prefix=/usr --with-libevent=/usr --with-boost=/usr
sudo make
sudo make install
安装过程中容易碰到的问题:
1.下面这个错误可能是因为DOS(Windows)和Unix文件格式问题:
checking whether g++ supports C++11 features by default... no
checking whether g++ supports C++11 features with -std=c++11... no
configure: No compiler with C++11 support was found
./configure: line 16746: syntax error near unexpected token `fi'
./configure: line 16746: `fi'
解决方法是设置好git:
[core]
autocrlf = false
safecrlf = true
eol = lf
对应的命令为:
git config --global core.autocrlf false
git config --global core.safecrlf true
git config --global core.eol lf
完成后,删除再重新从git上clone出来。
2..ibtoolize: AC_CONFIG_MACRO_DIR([./aclocal]) conflicts with aclocal_AMFLAGS=-I ./aclocal 执行libtoolize遇到上面提示的错误时,可能是因为configure.ac和Makefile.am文件是dos格式导致的。这个问题跟上面那个解决方案一致,或者直接修改文件格式见:http://www.cnblogs.com/573583868wuy/p/4009546.html(不太建议这样干,单个文件可以这样,文件多了就比较坑了)。
3.
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report
具体步骤请参见 <http://bugzilla.redhat.com/bugzilla>。
make[3]: *** [src/thrift/generate/thrift-t_c_glib_generator.o] 错误 1
make[3]: Leaving directory `/home/will/thrift-0.10.0/compiler/cpp'
make[2]: *** [all-recursive] 错误 1
make[2]: Leaving directory `/home/will/thrift-0.10.0/compiler/cpp'
make[1]: *** [all-recursive] 错误 1
make[1]: Leaving directory `/home/will/thrift-0.10.0'
make: *** [all] 错误 2
主要原因大体上是因为内存不足,可以 临时使用交换分区来解决,最好是添加物理内存
sudo dd if=/dev/zero of=/swapfile bs=64M count=16
sudo mkswap /swapfile
sudo swapon /swapfile