步骤
- 主要参考的是官方文档: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
- 其他提示安装的库,但不是所有库都需要
- 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种,推荐第一种:
|