ubuntu16.04 grpc安装

1. 安装3.13以上的cmake

apt remove cmake

wget https://cmake.org/files/v3.17/cmake-3.17.2.tar.gz

tar zxvf cmake-3.17.2.tar.gz

cd cmake-3.17.2

./configure

sudo make && make install

2. 安装openssl

apt remove openssl

wget https://www.openssl.org/source/openssl-1.1.1b.tar.gz

tar -xvf openssl-1.1.1b.tar.gz

cd openssl-1.1.1b

./config --prefix=/usr/local --openssldir=/usr/local/openssl

make && make install

vim ~/.bashrc

export PATH=/usr/local/openssl/bin:${PATH}

export OPENSSL_ROOT_DIR=/usr/local/openssl

export OPENSSL_LIBRARIES=/usr/local/openssl/lib

source ~/.bashrc

3. 安装grpc工具

sudo apt install -y build-essential autoconf libtool pkg-config

4. 下载grpc

git clone -b v1.28.0 https://github.com/grpc/grpc.git
cd grpc
git submodule update --init

5. 安装grpc的absl依赖

# Install openssl (to use instead of boringssl)
apt-get update && apt-get install -y libssl-dev
cd grpc/third_party/abseil-cpp/cmake/build
mkdir build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ..
make install

6. 安装grpc的c-ares依赖

# Install c-ares
# If the distribution provides a new-enough version of c-ares,
# this section can be replaced with:
# apt-get install -y libc-ares-dev
cd grpc/third_party/cares/cares
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make install

7. 安装grpc的benchmarks依赖

cd grpc/third_party/benchmarks
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make install

8. 安装grpc的protobuf依赖

cd grpc/third_party/protobuf/cmake
mkdir build
cd build
cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ..
make install

9. 安装grpc的zlib依赖

cd grpc/third_party/zlib
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make install

10.安装grpc

cd grpc
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release \
  -DgRPC_INSTALL=ON \
  -DgRPC_BUILD_TESTS=OFF \
  -DgRPC_CARES_PROVIDER=package \
  -DgRPC_ABSL_PROVIDER=package \
  -DgRPC_PROTOBUF_PROVIDER=package \
  -DgRPC_SSL_PROVIDER=package \
  -DgRPC_ZLIB_PROVIDER=package ..
make install

11.构建hello world

cd grpc/examples/cpp/helloworld
mkdir build
cd build
cmake ..
make

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值