环境配置
Thrift 库
这个 Thrift
是一个轻量级的,跨语言的 rpc
库。安装这个库,我们首先需要安装它需要的依赖。
sh
# 相关依赖工具
sudo yum install automake \
libtool \
flex \
bison \
pkgconfig \
gcc-c++ \
boost-devel \
libevent-devel \
zlib-devel \
python-devel \
ruby-devel
然后下载对应的 Thrift
的版本安装包,同时解压,安装
sh
# 下载源代码,这里以 0.21.0 为例
wget https://github.com/apache/thrift/archive/refs/tags/v0.21.0.zip
# 然后解压
unzip v0.21.0.zip
# 然后进入文件目录
cd thrift-0.21.0
# 然后执行 sh 脚本
./bootstrap.sh
# 加载编译配置
./configure --with-cpp --with-boost --with-python --without-csharp --with-java --without-erlang --without-perl --with-php --without-php_extension --without-ruby --without-haskell --without-go
# 编译
make -j4
# 安装
sudo make install
我在安装 Thrift
的时候,遇到找不到一个 boost
静态库(libboost_unit_test_framework.a
)的问题,后来找到了解决方案,这里记录一下
sh
# 下载 boost 库的源代码
wget https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz
# 解压文件
tar xvf boost_1_87_0.tar.gz
# 进入文件目录、执行配置脚本
cd boost_1_87_0
./bootstrap.sh
./b2 --build-type=complete --layout=versioned link=static
!note\] 这里执行 `./b2` 的时候,一定要带上后面的参数,不然无法生成静态库
Glog 库
这里一个 Google
的日志库,配置这个外部依赖并不复杂
sh
# 获取源代码
wget https://github.com/google/glog/archive/refs/tags/v0.6.0.zip
# 解压
unzip v0.6.0.zip
# 进入文件目录、创建 build 文件夹
cd glog-0.6.0 && mkdir build
# 构建cmake、编译
cmake .. && make -j4
# 安装
sudo make install
Gflags 库
这是一个用于处理命令行标志的库,一般和 Google
其他库一起使用,其提供了一种简单的方法来定义和解析程序的命令行参数,增强程序的可配置性和灵活性。
sh
# 下载源码
wget https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.zip
# 解压
unzip v2.2.2.zip
# 进入目录文件、创建 build
cd gflags-2.2.2 && mkdir build
# 加载 cmake 配置
cmake ..
# 编译、安装
make -j4 && sudo make install