Linux编译安装brpc

一、安装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

你可能感兴趣的:(RPC,linux,rpc)