title: linux下安装thrift填坑记 date: 2019-05-22 19:19:40 categories:
thrift
引言
(基于centos6)最近想安装个thrift来玩玩,看了网上的一些安装教程,报了一大堆的错,查了无数的资料,搞了一天,终于安装好了。。。
安装
yum -y update
yum
install wget
yum
install git
yum
install gcc gcc-c++
yum
install libevent-devel zlib-devel openssl-devel
yum
install m4
yum
install glibc-devel glibc glib2 glib2-devel
yum
install autoconf-2.69
wget http://mirrors.ustc.edu.cn/gnu/libtool/libtool-2.4.6.tar.gz
tar -xvf libtool-2.4.6.tar.gz
cd libtool-2.4.6
./bootstrap
./configure
make &make install
cd ..
wget http://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.gz
tar -xvf bison-3.0.4.tar.gz
cd bison-3.0.4
./configure --prefix
=/usr/soft/bison
make &make install
cd ..
wget http://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_64_0.tar.gz
tar -xvf boost_1_64_0.tar.gz
cd boost_1_64_0
./bootstrap.sh
./b2
install
cd ..
git clone https://github.com/apache/thrift.git
cd thrift
./bootstrap.sh
./configure --prefix
=/usr/soft/thrift --with-boost
=/usr/soft/bootstrap/
./configure: line 3802: PKG_PROG_PKG_CONFIG:
command not found
./configure: line 18272: syntax error near unexpected token
`QT,'
./configure: line 18272: ` PKG_CHECK_MODULES
(QT, QtCore
>= 4.3, QtNetwork
>= 4.3, have_qt
=yes, have_qt
=no
)
find /usr -name
"pkg.m4" 返回 /usr/share/aclocal/pkg.m4
aclocal --print-ac-dir 返回 /usr/local/share/aclocal
#这导致定义在 pkg.m4里全局变量 PKG_PROG_PKG_CONFIG 与 PKG_CHECK_MODULES 找不到,所以报错
#做如下修改解决这个问题, 在bootstrap.sh 里面修改
aclocal -I ./aclocal -I /usr/share/aclocal/
#保存 重新从 ./bootstrap.sh 就可以了!
#然后继续
make &make install
#若出现如下错误,NO.2-------------------------------------------------------------------2
#搞忘了,反正错误就是你的gcc版本太低了,需要升级
#下载gcc-4.8
wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.0/gcc-4.8.0.tar.bz2
tar jxvf gcc-4.8.0.tar.bz2
#下载编译所需依赖库
cd gcc-4.8.0
./contrib/download_prerequisites
cd ..
#编译安装
mkdir gcc-build-4.8.0
cd gcc-build-4.8.0
../gcc-4.8.0/configure --enable-checking
=release --enable-languages
=c,c++ --disable-multilib
make -j 8
make install
gcc -v
#若出现如下错误,NO.3-------------------------------------------------------------------3
./src/thrift/server/TNonblockingServer.h:41:33: error: event2/event_compat.h: No such
file or directory
#找不到event2的头文件
#直接去官网下载
#https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
#安装编译
./configure --prefix
=/usr/local
make
make install
#若出现如下错误,NO.4-------------------------------------------------------------------4
/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.18' not found
strings /usr/lib/libstdc++.so.6
| grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
...
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH
ll /usr/lib/libstdc++.so.6
/usr/lib/libstdc++.so.6 -
> libstdc++.so.6.0.13
find / -name libstdc++.so.6*
/usr/lib64/libstdc++.so.6.bak
/usr/lib64/libstdc++.so.6.0.13
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.20
/usr/local/lib64/libstdc++.so.6
/usr/local/lib64/libstdc++.so.6.0.18-gdb.py
/usr/local/lib64/libstdc++.so.6.0.18
strings /usr/local/lib/libstdc++.so.6.0.18
| grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
...
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH
cp /usr/local/lib/libstdc++.so.6.0.20 /usr/lib64/libstdc++.so.6.0.18
rm -f /usr/lib/libstdc++.so.6
ln -s /usr/lib/libstdc++.so.6.0.20 /usr/lib64/libstdc++.so.6
g++: error: /usr/lib/libboost_unit_test_framework.a: No such
file or directory
find / -name libboost_unit_test_framework.a
/usr/local/lib/libboost_unit_test_framework.a
sudo ln -s /usr/local/lib/libboost_unit_test_framework.a /usr/lib/libboost_unit_test_framework.a
make &make install
成功