Windows下C++使用grpc

Windows下使用grpc

安装grpc

参考 https://blog.csdn.net/danxingxian_go/article/details/104176878

git clone https://github.com/grpc/grpc.git
cd grpc
git submodule update --init #会拉取比较多的代码
编译x64
windows在windows shell模式下可以使用cmake,如果不行需要安装cmake
切至grpc目录 
mkdir build
cd bulid
cmake .. -G "Visual Studio 16 2019" -A x64

cmake后会创建vs工程,ALL_BUILD执行 然后INSTALL进行安装,细节可参考链接
当前有有出现一个错误,在生成grpc.lib时编译失败
错误类似“‘string’ : is not a member of ‘std’, header file problem”
修复: 在对应错误文件中加上 #include<string> 可以修复

使用grpc

在使用grpc时需要安装protoc,对于源码安装grpc时会对应生成protoc.exe文件
在尝试编译helloworld.proto用例时出错

protoc -I. --grpc_out=./ --plugin=protoc_gen-grpc=grpc_cpp_plugin helloworld.proto
'protoc-gen-grpc' 不是内部或外部命令,也不是可运行的程序或批处理文件。
--grpc_out: protoc-gen-grpc: Plugin failed with status code 1.

解决办法:protoc-gen-grpc对应plugin需要为绝对路径

protoc -I. --grpc_out=./ --plugin=protoc-gen-grpc="C:\\Program Files (x86)\\grpc\\bin\\grpc_cpp_plugin.exe" helloworld.proto

其他的可以参考的用例比较多

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值