zl程序教程

您现在的位置是:首页 >  其他

当前栏目

【Ubuntu16.04 】安装gRPC详细步骤(cmake>=3.13)

安装 详细 步骤 CMake ubuntu16.04 grpc
2023-09-14 09:05:34 时间

1、安装相关依赖工具

#安装pkg-config
sudo apt-get install pkg-config
#安装依赖文件
sudo apt-get install autoconf automake libtool make g++ unzip
sudo apt-get install libgflags-dev libgtest-dev
sudo apt-get install clang libc++-dev

2、下载gRPC 源码

git clone https://github.com/grpc/grpc.git
cd grpc
git submodule update --init  #更新第三方源码

遇到问题:

如果此时更新第三方源码,失败或者连接失败时候,如:

 一系列问题的时候,执行如下命令:

sudo gedit .gitmodules

 把 url 里面的 https 更改为 git(全部都要更改)

接下来就需要耐心等待,多尝试几次更新命令;

3、配置其他依赖

通过cmake来实现编译,因而需要自行安装cmake。(cmake版本可能比较老)建议自行安装cmake。

sudo apt install cmake

同时还需要安装其他基础依赖,使用如下命令:

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

然后执行命令:

mkdir -p cmake/build
cd cmake/build
cmake ../..
make

其中cmake编译的相关flag为:

cmake \
  -DCMAKE_BUILD_TYPE=Release \
  -DgRPC_INSTALL=ON \
  -DgRPC_BUILD_TESTS=OFF \
  -DgRPC_SSL_PROVIDER=package \
  ../..
sudo make -j4 install