第1步:安装protobuf
- https://github.com/protocolbuffers/protobuf/releases 下载最新版本protobuf-cpp-3.6.1.tar.gz
- tar -zxvf protobuf-cpp-3.6.1.tar.gz
- cd protobuf-3.6.1/
- ./autogen.sh && ./configure
- make && sudo make install
第2步: 安装grpc
- git clone https://github.com/grpc/grpc.git
- cd grpc
- git submodule update --init
- make && sudo make install
第3步:运行实例
- cd grpc/examples/cpp/route_guide (代码分析见这里)
- make route_guide.grpc.pb.cc route_guide.pb.cc (生成客户端和服务器端代码)
- make (编译代码)
- export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
- export LD_LIBRARY_PATH=/usr/local/lib/:/home/$user/grpc/libs/opt/
- ./route_guide_server (运行服务端)
- ./route_guide_client (运行客户端)
以上内容经过测试验证
参考内容:https://doc.oschina.net/grpc?t=57966