window 系统源码编译grpc库

步骤

  • 主要参考的是官方文档: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 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 = on
        • GOPROXY = https://mirrors.aliyun.com/goproxy,https://goproxy.io,https://goproxy.cn
          在这里插入图片描述
      • cmd执行go env -w GOPROXY=https://goproxy.cn,再编译

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值