- 主要参考的是官方文档:https://github.com/grpc/grpc/blob/master/BUILDING.md
- 其他安装的教程博客
- 依赖库:
- Install Visual Studio 2015 or 2017 (Visual C++ compiler will be used).
- Install Git.
- Install CMake.
- Install nasm, perl,go and add it to PATH (choco install nasm) - required by boringssl
- (Optional) Install Ninja (choco install ninja)
- 编译前准备:由于国内访问限制,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 Studio2017ProfessionalCommon7IDEVCVCTargetsMicrosoft.CppCommon.targets(209,5): error MSB6006: “cmd.exe”已退出,代码为 1。 [D:sdkgrpc-mastergrpc-1.45.1build_64third_partyboringssl-with-bazelcrypto_test_data.vcxproj]
- 报错原因:国内go包管理的代理网址无法访问,解决办法如下2种,推荐第一种:
-
添加两组用户环境变量即可
- GO111MODULE = on
- GOPROXY = https://mirrors.aliyun.com/goproxy,https://goproxy.io,https://goproxy.cn
-
cmd执行go env -w GOPROXY=https://goproxy.cn,再编译
-
- 报错原因:国内go包管理的代理网址无法访问,解决办法如下2种,推荐第一种:



