ubuntu下安装编译grpc与protobuf

官网链接安装

安装基础依赖

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

安装 Protobuf

  • 可以通过包管理器直接安装
sudo apt install -y protobuf-compiler
protoc --version  # 确认安装成功,应该显示版本号
  • 指定版本,可按如下方式从源码编译安装:
# 下载源码
git clone -b v25.1 --depth 1 https://github.com/protocolbuffers/protobuf.git
cd protobuf
# 配置、编译并安装
./configure
make -j$(nproc)
make check
sudo make install
sudo ldconfig  # 更新共享库缓存
cd ..

安装 gRPC

# 下载gRPC源码
git clone -b v1.58.0 --depth 1 https://github.com/grpc/grpc.git
cd grpc
git submodule update --init
# 编译并安装
mkdir -p cmake/build
cd cmake/build
cmake -DgRPC_INSTALL=ON \
      -DgRPC_BUILD_TESTS=OFF \
      -DCMAKE_INSTALL_PREFIX=/usr/local \
      ../..
make -j$(nproc)
sudo make install
cd ../../../
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值