C++网络编程(一)gRPC的编译

Google是真滴烦,整个编译链全是自家产品,在编译之前先来安装一堆东西

安装环境依赖

  1. chocolatey Windows下的包管理系统,没有他就慢慢去下载下面的一堆乱七八糟的东西吧。CMD下执行下面这句话就可以安装了。
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
  1. Git
  2. Visual Studio 2015 or 2017 这个你懂的.
  3. CMake.
  4. Active State Perl (choco install activeperl) - perl会被gRPC的第三方依赖 boringssl 使用到
  5. Go (choco install golang) - 会被gRPC的第三方依赖 boringssl 使用到(我只是个C++强行给我装上了GO)
  6. yasm and add it to PATH (choco install yasm) - 也会被gRPC的第三方依赖 boringssl 使用到(麻烦死了)
  7. 可选Ninja (choco install ninja)

下载源代码依赖

如果你装了chocolatey,你就可以用括号里的choco命令来安装东西了 还没完,上面只是环境依赖,接下来下载源代码依赖。

把依赖分别解压到grpc-1.20.0\third_party\对应的依赖包下面去
1.c-cares 解压到grpc-1.20.0\third_party\cares\cares
2. boringssl解压到grpc-1.20.0\third_party\boringssl
3. gflags解压到grpc-1.20.0\third_party\gflags
4. zlib解压到grpc-1.20.0\third_party\zlib
5. benchmark解压到grpc-1.20.0\third_party\benchmark
6. protobuf解压到grpc-1.20.0\third_party\protobuf
完成上面的事情后输入CMD指令:

md .build
cd .build

新建编译文件夹然后cd进去,接下来编译

我的编译器是Visual Studio 15 2017,所以指定编译器是Visual Studio 15 2017,如果是2015,则是Visual Studio 14 2015

cmake .. -G "Visual Studio 15 2017"

注意:如果是64位编译就是

cmake .. -G "Visual Studio 15 2017 Win64"

最后,编译Release版本,如果不加Release则默认为Debug版本

cmake --build . --config Release

结果。。。。。。。。。
编译了21分钟不说。。。。。还报错了。。惊了
既然知道在grpc-1.20.0\third_party\boringssl\tool\transport_common.cc(19)这个地方,找过去。

微软是这么说的

调用 c + + 标准库中的任何潜在的不安全的方法会导致编译器警告 (等级 3) C4996。 若要禁用此警告,请在代码中定义宏 _SCL_SECURE_NO_WARNINGS:

参考

好了bb这么多直接注释掉就好了。。。。。。
再来一次build all

嗯,完工

转载于:https://my.oschina.net/VenusV/blog/3039571

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值