bRPC 编译、安装与样例测试。
系统环境
- Ubuntu 18.04 以上
- gcc 4.x ~ 11.x
- brpc-1.5.0
3 个特定版本的关键依赖:
- gflags-2.2.2
- protobuf-3.20.0
- glog-0.4.0
后文的依赖和项目的路径:
/users/CS0522/bthread-dep/gflags-2.2.2/
/users/CS0522/bthread-dep/protobuf/
/users/CS0522/bthread-dep/glog-0.4.0/
/users/CS0522/custom-brpc/brpc/
安装依赖
安装其他依赖
openssl、leveldb、ibverbs,以及静态链接 leveldb 的依赖:
安装关键依赖
按顺序安装!
安装 gflags:
# /users/CS0522/bthread-dep/gflags-2.2.2
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON -DGFLAGS_NAMESPACE=google -DCMAKE_HAVE_LIBC_PTHREAD=ON -G "Unix Makefiles" -DBUILD_SHARED_LIBS=1 -DBUILD_STATIC_LIBS=1 ../
make -j16
sudo make install
sudo systemctl daemon-reload
sudo ldconfig
安装 protobuf:
# /users/CS0522/bthread-dep/protobuf/
make clean && make distclean
./configure --prefix=/usr/local
make -j16
sudo make install
sudo systemctl daemon-reload
sudo ldconfig
安装 glog:
编译 brpc
echo 样例测试
修改 CMakeLists.txt
新的压缩包 custom-bprc.zip
中已经修改好:
# /users/CS0522/custom-brpc/brpc/example/echo_c++/
vim CMakeLists.txt
# 添加 glog
find_library(GLOG_LIB NAMES glog/logging.h)
find_path(GLOG_INCLUDE_PATH NAMES glog)
if (NOT GLOG_LIB)
set(GLOG_LIB "")
set(GLOG_INCLUDE_PATH "")
endif()
include_directories(${GLOG_INCLUDE_PATH})
# set DYNAMIC_LIB 中添加 GLOG_LIB
set(DYNAMIC_LIB
...
${GLOG_LIB}
dl
)
# 保存退出