yum install -y gcc gcc-c++ autoconf libtool yum groupinstall -y "Development Tools"
git clone https://github.com/grpc/grpc.git cd grpc git submodule update --init
cd third_party/protobuf/
./autogen.sh
./configure
make
make install ldconfig # refresh shared library cache. which protoc protoc --version
autogen.sh裏須要下載Google Code的代碼,須要保障其能被訪問javascript
cd ../.. make
問題:java
/root/git/grpc/bins/opt/grpc_cpp_plugin: error while loading shared libraries: libprotoc.so.15: cannot open shared object file: No such file or directory
解決辦法:c++
echo $LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/lib/:/root/git/grpc/libs/opt/ make make install
cd examples/cpp/helloworld make
問題:git
Package protobuf was not found in the pkg-config search path. Perhaps you should add the directory containing `protobuf.pc' to the PKG_CONFIG_PATH environment variable No package 'protobuf' found
解決辦法:github
echo $PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/root/git/grpc/libs/opt/pkgconfig:/root/git/grpc/third_party/protobuf make ./greeter_server & ./greeter_client
經常使用命令:
/usr/local/bin/protoc --cpp_out=./ examples.proto
/usr/local/bin/protoc --grpc_out=./ --plugin=protoc-gen-grpc=/usr/local/bin/grpc_cpp_plugin examples.protosql