linux下安装thrift填坑记

    xiaoxiao2022-07-06  194


    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 #autoconf yum install autoconf-2.69 #libtool 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 .. #bison 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 .. #bootstrap 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 .. #thrift,若时间很久,直接去官网下载吧 #http://www.apache.org/dyn/closer.cgi?path=/thrift/0.12.0/thrift-0.12.0.tar.gz git clone https://github.com/apache/thrift.git cd thrift ./bootstrap.sh ./configure --prefix=/usr/soft/thrift --with-boost=/usr/soft/bootstrap/ #若出现如下错误,NO.1--------------------------------------------------------------------1 ./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 #这两个地址不一样,再加上 bootstrap.sh 里面定义了 aclocal -I ./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 #这是因为升级gcc时,生成的动态库没有替换老版本gcc的动态库,将gcc最新版本的动态库替换掉老版本的动态库即可 #查看GLBCXX版本 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 #可以看到,最高版本为3.4.13,没有对应的3.4.18 #查看libstdc++.so.6链接的库 ll /usr/lib/libstdc++.so.6 #输出,这是libstdc++.so.6现在链接的库 /usr/lib/libstdc++.so.6 -> libstdc++.so.6.0.13 #查看系统更高版本的lib库 find / -name libstdc++.so.6* #输出,这里有一个6.0.18版本,比libstdc++.so.6.0.13版本更高 /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 #查看lib库的信息 strings /usr/local/lib/libstdc++.so.6.0.18 | grep GLIBCXX #输出,18这个版本满足我们的需求 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 #若出现如下错误,NO.5-------------------------------------------------------------------5 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 成功
    最新回复(0)