步骤
- 主要参考的是官方文档:https://github.com/grpc/grpc/blob/master/BUILDING.md
- 其他安装的教程博客
- 依赖库:
- 编译前准备:由于国内访问限制,build.md依赖的子模块库难以在线下载,因此采取手动下载或者逐个git下载到特定的目录,third_party
- https://github.com/madler/zlib
- https://github.com/protocolbuffers/protobuf.git
- https://github.com/google/benchmark.git
- https://github.com/google/boringssl.git
- https://github.com/c-ares/c-ares.git
- https://github.com/abseil/abseil-cpp.git
- 其他提示安装的库,但不是所有库都需要
- 或添加github镜像链接:https://hub.xn–gzu630h.xn–kpry57d/
- cmd执行以下dos命令
md .build
cd .build
cmake … -G “Visual Studio 14 2015 Win64”
cmake --build . --config Release`
踩坑
- 提示找不到
openssl/ssl.h,原因是添加的ssl开源库的头文件有误,修改grpc源码所在目录的cmake/ssl.cmake中第46行set(_gRPC_SSL_INCLUDE_DIR ${BORINGSSL_ROOT_DIR}/src/include). 可以验证应该改为set(_gRPC_SSL_INCLUDE_DIR ${BORINGSSL_ROOT_DIR}/include) - 提示编译
crypto库报错,如下go: golang.org/x/crypto@v0.0.0-20210513164829-c07d793c2f9a: Get "https://proxy.golang.org/golang.org/x/crypto/@v/v0.0.0-20210513164829-c07d793c2f9a.mod": dial tcp 142.251.42.241:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5): error MSB6006: “cmd.exe”已退出,代码为 1。 [D:\sdk\grpc-master\grpc-1.45.1\build_64\third_party\boringssl-with-bazel\crypto_test_data.vcxproj]- 报错原因:国内go包管理的代理网址无法访问,解决办法如下2种,推荐第一种:
-
添加两组用户环境变量即可
GO111MODULE = onGOPROXY = https://mirrors.aliyun.com/goproxy,https://goproxy.io,https://goproxy.cn

-
cmd执行
go env -w GOPROXY=https://goproxy.cn,再编译
-
- 报错原因:国内go包管理的代理网址无法访问,解决办法如下2种,推荐第一种:
本文档详细介绍了在Windows环境下手动下载并配置gRPC编译环境的步骤,包括安装Visual Studio、Git、CMake、nasm等依赖,并特别指出了解决国内访问GitHub限制的方法,如设置Go代理。在编译过程中遇到的openssl头文件路径错误和Go包下载失败的问题,提供了修改cmake文件和设置Go代理环境变量的解决方案。
2271

被折叠的 条评论
为什么被折叠?



