grpc 1.0.0 (c++) 源码编译安装

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

转载于:https://my.oschina.net/dlbob/blog/743802

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值