栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Go语言

window 系统源码编译grpc库

Go语言 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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 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,再编译

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/937821.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号