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
也会出错,cd
到thirdparty/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
- error in autogen.sh? #2604
- Cannot build and install: Missing configure #945
- Protobuf cannot find shared libraries