gRPC compiling with Visual Studio 2019 on Windows 10

简介

在Windows上源码编译安装gRPC需要MSVC编译器、git、cmake、Perl、go、yasm、Ninja等工具,一些工具的安装可以使用choco(Windows上的包管理工具)来安装。

gRPC官方Windows安装说明:

  • Install Visual Studio 2019 (Visual C++ compiler will be used).
  • Install Git
  • Install CMake
  • Install Active State Perl (choco install activeperl) - required by boringssl
  • Install Go (choco install golang) - required by boringssl
  • Install yasm and add it to PATH (choco install yasm) - required by boringssl
  • (Optional) Install Ninja (choco install ninja)

准备环境

choco install activeperl
choco install golang
choco install yasm
choco install ninja

下载gRPC源码

  • 下载代码
git clone -b RELEASE_TAG_HERE https://github.com/grpc/grpc.git
  • 下载依赖
git submodule update  --init
  • 屏蔽警告(可选)

下载完毕后,打开文件./grpc/third_party/zlib/gzguts.h,修改如下:

#ifdef _WIN32
#inlcude <stddef.h>
#endif

改为

#ifdef _WIN32
#include <stddef.h>
#pragma warning(disable:4996)
#endif

VS2019 编译gRPC源码

生成grpc.sln

md .build
cd .build
cmake .. -G "Visual Studio 16 2019" #-DCMAKE_BUILD_TYPE=Release

编译

选择 :“ALL_BUILD”

安装

选择 :“INSTALL”

Example

  • 预处理
    _WIN32_WINNT=0x0A00
  • 链接库
    Ws2_32.lib
    libprotobufd.lib
    grpc.lib
    grpc++.lib
    gpr.lib
    zlibd.lib
    cares.lib
    address_sorting.lib
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值