Ubuntu16.04.5环境编译grpc小记

都是坑

Posted by cj on December 19, 2018

Ubuntu16.04.5环境编译grpc小记

1. 初始化环境

执行脚本

2. 编译

2.1 按照官方教程编译

git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc
cd grpc
git submodule update --init
make
sudo make install

其中在执行make时报错protobuf configure.ac:104: error: possibly undefined macro: AC_PROG_LIBTOOL,需要安装libtool

sudo apt-get install libtool-bin -y

我记得中间还有一次报错,找不到autoreconf,安装autoconf解决:

sudo apt-get install autoconf -y

好像之后再make也会出错,cdthirdparty/protobuf目录后执行./autogen.sh && ./configure && make && sudo make install后再返回grpc根目录再次make成功,然后执行sudo make install成功。

2.2 Build and install gRPC PHP extension

会提示phpize未安装,先安装:

sudo apt-get install php7.2-dev -y

再编译

cd grpc/src/php/ext/grpc
phpize
./configure
make
sudo make install

2.3 protoc出错

执行protoc --version 测试时报错:

protoc: error while loading shared libraries: libprotoc.so.17: cannot open shared object file: No such file or directory

执行sudo ldconfig解决。

2.4 编译examples/cpp/helloworld报错

错误信息:

/bin/sh: 1: pkg-config: not found

安装pkg-config解决:

sudo apt-get install pkg-config -y

Reference