gcc 4.4
git clone https://github.com/grpc/grpc.git
cd grpc
git submodule update --init
#编译proto3
cd grpc/third_party/protobuf
#./tests.sh
./autogen.sh
./configure --prefix=/usr/local CXXFLAGS="$(pkg-config --cflags protobuf)" LIBS="$(pkg-config --libs protobuf)"
make -j2
make check
make install
ldconfig
#pkg-config --cflags protobuf # print compiler flags
#pkg-config --libs protobuf # print linker flags
#pkg-config --cflags --libs protobuf # print both
#c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf`
#编译grpc-plugin(c++、object-c、python、ruby、c#、node)
cd grpc_root_dir/third_party/
wget "https://www.openssl.org/source/openssl-1.0.2h.tar.gz"
sed -i 's/openssl-1.0.2f/openssl-1.0.2h/g' Makefile
./config --prefix=/usr --openssldir=/etc/ssl --libdir=lib shared zlib-dynamic && make depend && make -j2
cd grpc_root_dir
修改Makefile line:358 增加编译器优化选项 CPPFLAGS 关闭未初始化检查 -Wno-uninitialized
CPPFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter -Wno-uninitialized //uninitialized:使用的变量未初始化,只在-O2时有效;
make -j4 && make install
//test
cd grpc_root_dir/examples/protos/
$ protoc -I ../../protos --grpc_out=./ --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ../../protos/route_guide.proto
$ protoc -I ../../protos --cpp_out=./ ../../protos/route_guide.proto
$ protoc -I ../../protos --objc_out=./ ../../protos/route_guide.proto
参考官方略有修改:http://www.grpc.io/docs/quickstart/cpp.html