Windows系统下编译grpc源码+VS2019配置使用grpc | 您所在的位置:网站首页 › 编译gromacs卡死 › Windows系统下编译grpc源码+VS2019配置使用grpc |
Windows系统下编译grpc+VS2019配置使用grpc
导语: 本文记录了开源通信框架grpc在windows系统上编译的过程,以及使用VS 2019配置使用编译出来的grpc相关成果物展示demo.在window下编译grpc也是无奈啊,试过好多种办法(通过msys配置等),都不能为VS所用,所以只能开启一段旅程。 网上相关资料也有很多,这里基于grpc 和 VS 最新版本丰富下细节,做一下记录。 Step-1: 编译grpc 1-1 准备编译环境(1) 安装Git 作用:下载grpc代码以及相关的第三方库代码。 参考:https://git-scm.com/ (2) 安装CMake 作用:用来编译 参考:https://cmake.org/download/ 备注:将Cmake bin 目录配置到系统环境变量Path。 (3) 安装Perl 作用:grpc依赖的第三方库依赖的包。 参考:安装配置perl (4) 安装Go 作用:grpc依赖的第三方库依赖的包。 参考:安装配置Go (5) 安装yasm 作用:grpc依赖的第三方库依赖的包。 参考:安装配置yasm 备注:将vsyasm.exe所在目录配置到系统环境变量Path。 (6) 安装ninja 作用:grpc依赖的第三方库依赖的包。 参考:安装配置ninja 备注:将ninja.exe所在目录配置到系统环境变量Path。 这里面 perl go yasm ninja 可以用通过Choco(windows上的包管理工具安装),但是不推荐,除非你有梯子 1-2 下载grpc源码以及第三方依赖库源码(1) 网速快或者有梯子的情况下,git bash下直接执行如下命令,然后耐心等待就可以了。 git clone https://github.com/grpc/grpc.git git submodule update --init安静的等待就行。 (2) 网速慢的情况下,git bash下直接执行如下命令 git clone https://gitclone.com/github.com/grpc/grpc.git git submodule update --init执行完上述命令,可能会卡住,别慌Ctrl+C退出即可。 cd third_party/ git clone https://gitclone.com/github.com/abseil/abseil-cpp.git git clone https://gitclone.com/github.com/google/benchmark.git git clone https://gitclone.com/github.com/google/bloaty.git git clone https://gitclone.com/github.com/google/boringssl.git git clone https://gitclone.com/github.com/c-ares/c-ares.git git clone https://gitclone.com/github.com/envoyproxy/data-plane-api.git git clone https://gitclone.com/github.com/gflags/gflags.git git clone https://gitclone.com/github.com/googleapis/googleapis.git git clone https://gitclone.com/github.com/google/googletest.git git clone https://gitclone.com/github.com/libuv/libuv.git git clone https://gitclone.com/github.com/google/protobuf.git git clone https://gitclone.com/github.com/envoyproxy/protoc-gen-validate.git git clone https://gitclone.com/github.com/cncf/udpa.git git clone https://gitclone.com/github.com/madler/zlib.git如果个别库还是下载不下来,可以上github上用新的git url下载,或者直接下载代码包解压到相依目录。 注意下载完第三方库的源码后,有些目录需要调整到执行完git submodule update --init 一致的要求,否则Cmake的时候路径不对,例如:boringssl- -> boringssl-with-bazel /c-ares -->/cares/cares data-plane-api --> envoy-api 1-3 编译(1) 修改编译脚本错误 由于历史原因,请更改grpc/cmake/ssl.cmake set(_gRPC_SSL_INCLUDE_DIR ${BORINGSSL_ROOT_DIR}/src/include) --> set(_gRPC_SSL_INCLUDE_DIR ${BORINGSSL_ROOT_DIR}/include)(2) 查询 cmake 支持的 VS 版本 cmake -G
(3) 编译 lunch cmd ,cd 到代码根目录,执行如下命令。 mkdir .build cd .build cmake .. -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release cmake --build .耐心等待编译结果, 过程中会有grpc.sln 生成,最后编译成功会生成grpc的相关lib,以及第三方的相关lib. grpc相关lib 主要在.build/debug/目录下 (1) VS2019解决方案下建立如下项目: 选择Debug – x64构建配置 注意请用编译出来的exe文件生成C++ 文件,否则编译时会提示版本错误。 2-1 配置VS项目环境(1) 配置include目录 项目右键–> 属性 VS 上先编译执行 server端,再执行client端: 结语:本文在形成过程中也参考很多之前网友的贡献,在此感谢。限于篇幅很多细节还是不能详细展开,但是大致脉络已经呈现,希望对大家能有所帮助。 |
今日新闻 |
推荐新闻 |
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 |