Linux编译安装brpc

本文详细介绍了如何安装brpc依赖的protobuf、gflags、leveldb和openssl,以及如何配置和编译brpc示例,包括echo_c++demo的构建和运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、安装brpc依赖项目

(1)安装 protobuf

wget https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protobuf-cpp-3.21.9.tar.gz
tar -zxvf protobuf-cpp-3.21.9.tar.gz
cd protobuf-3.21.9/
mkdir build && cd build
cmake -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DINSTALL_HEADERS=ON -DINSTALL_SHARED_LIBS=ON -DINSTALL_STATIC_LIBS=ON ..
make -j4
make install
protoc --version

(2)安装gflags

wget https://github.com/gflags/gflags/archive/v2.2.2.tar.gz
mkdir build && cd build/
cmake -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DINSTALL_HEADERS=ON -DINSTALL_SHARED_LIBS=ON -DINSTALL_STATIC_LIBS=ON ..
make -j4
make install

(3)安装leveldb(需要单独下载两个依赖项目)

wget https://github.com/google/leveldb/archive/refs/tags/1.23.tar.gz

依赖项目,从github下载,并解压到thrid_party文件夹
benchmark.zip
googletest.zip

https://github.com/google/googletest
https://github.com/google/benchmark

mkdir build && cd build/
cmake -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DINSTALL_HEADERS=ON -DINSTALL_SHARED_LIBS=ON -DINSTALL_STATIC_LIBS=ON ..
make -j4
make install

(4)安装openssl

wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1m.tar.gz
./config
make -j4
make install

二、编译brpc

git clone -b 1.6.0 https://github.com/apache/brpc.git
sh config_brpc.sh --headers="/usr/local/include" --libs="/usr/local/lib"
make -j4
export LD_LIBRARY_PATH=/usr/local/lib/

三、验证brpc

1)编译demo
cd /brpc/example/echo_c++
make -j4

(2)运行demo
./echo_server
./echo_client
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值