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
其他的可以参考的用例比较多