资讯 小学 初中 高中 语言 会计职称 学历提升 法考 计算机考试 医护考试 建工考试 教育百科
栏目分类:
子分类:
返回
空麓网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
空麓网 > 计算机考试 > 软件开发 > 后端开发 > Go语言

gRPC+PB实现不同语言之间函数调用 下载git子模块

Go语言 更新时间: 发布时间: 计算机考试归档 最新发布

gRPC+PB实现不同语言之间函数调用 下载git子模块

官网:https://grpc.io/   国内需VPN访问

最难的是C语言,C语言最难的是下载完整的包。

先看效果:
 

 环境:windows 10,VS2017,git,cmake 就够了。 一、下载完整的包
git clone --recurse-submodules -b v1.41.0 https://github.com/grpc/grpc

 如果下载第三方包时中断了,可以用下面继续下载。

git submodule update --init --recursive
 二、C++编译(其它语言可以直接使用库,不用做这步)
//环境变量新加一个MY_INSTALL_DIR   D:09protobuffgRPCgrpc 
//建目录手工建也行
cd grpc
mkdir cmake
cd cmake
mkdir build
cd build

//生成vs工程
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR ../..

 

用vs2017打开grpc.sln,点生成。

 

三、示例项目 1.编写proto文件 (grpcexamplesprotoshelloworld.proto) 2.生成C++代码并加入到项目中
//生成javaC++ protobuff类和grpc类
protoc --proto_path=./ --cpp_out=./out helloworld.proto
protoc --proto_path=./ --grpc_out=./out --plugin=protoc-gen-grpc="D:testgrpcgrpccmakebuildDebuggrpc_cpp_plugin.exe" helloworld.proto

//生成java
protoc --proto_path=./ --java_out=./out helloworld.proto

4个文件 

 

3.项目中使用

(1)依赖库

把所有的lib全部搜出来,复制到项目下,并加到 C/C++  链接器  输入  附加依赖项  里

absl_bad_any_cast_impl.lib;absl_bad_optional_access.lib;absl_bad_variant_access.lib;absl_base.lib;absl_city.lib;absl_civil_time.lib;absl_cord.lib;absl_debugging_internal.lib;absl_demangle_internal.lib;absl_examine_stack.lib;absl_exponential_biased.lib;absl_failure_signal_handler.lib;absl_flags.lib;absl_flags_commandlineflag.lib;absl_flags_commandlineflag_internal.lib;absl_flags_config.lib;absl_flags_internal.lib;absl_flags_marshalling.lib;absl_flags_parse.lib;absl_flags_private_handle_accessor.lib;absl_flags_program_name.lib;absl_flags_reflection.lib;absl_flags_usage.lib;absl_flags_usage_internal.lib;absl_graphcycles_internal.lib;absl_hash.lib;absl_hashtablez_sampler.lib;absl_int128.lib;absl_leak_check.lib;absl_leak_check_disable.lib;absl_log_severity.lib;absl_malloc_internal.lib;absl_periodic_sampler.lib;absl_random_distributions.lib;absl_random_internal_distribution_test_util.lib;absl_random_internal_platform.lib;absl_random_internal_pool_urbg.lib;absl_random_internal_randen.lib;absl_random_internal_randen_hwaes.lib;absl_random_internal_randen_hwaes_impl.lib;absl_random_internal_randen_slow.lib;absl_random_internal_seed_material.lib;absl_random_seed_gen_exception.lib;absl_random_seed_sequences.lib;absl_raw_hash_set.lib;absl_raw_logging_internal.lib;absl_scoped_set_env.lib;absl_spinlock_wait.lib;absl_stacktrace.lib;absl_status.lib;absl_statusor.lib;absl_strerror.lib;absl_strings.lib;absl_strings_internal.lib;absl_str_format_internal.lib;absl_symbolize.lib;absl_synchronization.lib;absl_throw_delegate.lib;absl_time.lib;absl_time_zone.lib;absl_wyhash.lib;address_sorting.lib;cares.lib;crypto.lib;gpr.lib;grpc++.lib;grpc++_alts.lib;grpc++_error_details.lib;grpc++_reflection.lib;grpc++_unsecure.lib;grpc.lib;grpcpp_channelz.lib;grpc_csharp_ext.lib;grpc_plugin_support.lib;grpc_unsecure.lib;libprotobuf-lited.lib;libprotobufd.lib;libprotocd.lib;re2.lib;ssl.lib;testing.lib;upb.lib;zlibd.lib;zlibstaticd.lib

 2.include

D:testgrpcgrpcthird_partyabseil-cpp;D:testgrpcgrpcinclude;D:testgrpcgrpcthird_partyprotobufsrc;$(IncludePath)

3.复制zlibd.dll到Debug 是上级目录的Debug

4.编译运行

       编译服务端时,请屏蔽掉客户端的main函数代码

  编译客户端时,请屏蔽掉服务端的main函数代码

  生成exe文件改名,并将zlibd.dll放在一起

完成。

附:其它(以下是弯路,没必要,有错) 

pushd命令用于更改新目录并(或)压栈,或者把栈里的某个目录推到栈顶。

echo %my_install_dir%

  gRPC_ABSL_PROVIDER is "module" but ABSL_ROOT_DIR is wrong

 第三方库没有准备好

linux如何安装这些?

$ sudo apt install -y build-essential autoconf libtool pkg-config

全下载再试,成功了。

cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR ../..

生成了vs工程。

下载git子模块

最快:

git clone --recurse-submodules -b v1.41.0 https://github.com/grpc/grpc

最终:新建一个git项目,一个一个的加子模块,先下载再复制到项目下,OK,终于全部下载下来了。 

过程,别试:

主库用gitee同步,可以快速下载。.gitsubmodule中子库(第三方库)怎么一下全部下载呢?

怎么命令不顶用?

git submodule update --recursive

 可能是因为我是zip下载的,git clone 下载后是可以用的。

但是子模块下载特别慢。我把所有子模块全同步到gitee

再改.submodules里所有链接到gitee  (大家如果用,最好先进我的gitee,每个都点下同步到最新)

[submodule "third_party/zlib"]
	path = third_party/zlib
	url = https://gitee.com/chenhao0568/zlib
	# When using CMake to build, the zlib submodule ends up with a
	# generated file that makes Git consider the submodule dirty. This
	# state can be ignored for day-to-day development on gRPC.
	ignore = dirty
[submodule "third_party/protobuf"]
	path = third_party/protobuf
	url = https://gitee.com/chenhao0568/protobuf.git
[submodule "third_party/googletest"]
	path = third_party/googletest
	url = https://gitee.com/chenhao0568/googletest.git
[submodule "third_party/benchmark"]
	path = third_party/benchmark
	url = https://github.com/google/benchmark
[submodule "third_party/boringssl-with-bazel"]
	path = third_party/boringssl-with-bazel
	url = https://gitee.com/chenhao0568/boringssl.git
[submodule "third_party/re2"]
	path = third_party/re2
	url = https://gitee.com/chenhao0568/re2.git
[submodule "third_party/cares/cares"]
	path = third_party/cares/cares
	url = https://gitee.com/chenhao0568/c-ares.git
	branch = cares-1_12_0
[submodule "third_party/bloaty"]
	path = third_party/bloaty
	url = https://gitee.com/chenhao0568/bloaty.git
[submodule "third_party/abseil-cpp"]
	path = third_party/abseil-cpp
	url = https://gitee.com/chenhao0568/abseil-cpp.git
	branch = lts_2020_02_25
[submodule "third_party/envoy-api"]
	path = third_party/envoy-api
	url = https://gitee.com/chenhao0568/data-plane-api.git
[submodule "third_party/googleapis"]
	path = third_party/googleapis
	url = https://gitee.com/chenhao0568/googleapis.git
[submodule "third_party/protoc-gen-validate"]
	path = third_party/protoc-gen-validate
	url = https://gitee.com/chenhao0568/protoc-gen-validate.git
[submodule "third_party/libuv"]
	path = third_party/libuv
	url = https://gitee.com/chenhao0568/libuv.git
[submodule "third_party/opencensus-proto"]
	path = third_party/opencensus-proto
	url = https://gitee.com/chenhao0568/opencensus-proto.git
[submodule "third_party/opentelemetry"]
	path = third_party/opentelemetry
	url = https://gitee.com/chenhao0568/opentelemetry-proto.git
[submodule "third_party/xds"]
	path = third_party/xds
	url = https://gitee.com/chenhao0568/cncf/xds.git
//新建一个分支
git branch gitee

//本地修改.gitmodules 地址全改为gitee

//提交
git commit 'from gitee OK'

//下载子模块
git submodule update --init --recursive

 不行。git中submodule修改子模块的git地址不起作用,还是原来的地址。

新建一个git项目,一个一个的加,OK,终于全部下载下来了。

转载请注明:文章转载自 http://www.konglu.com/
本文地址:http://www.konglu.com/it/990971.html
免责声明:

我们致力于保护作者版权,注重分享,被刊用文章【gRPC+PB实现不同语言之间函数调用 下载git子模块】因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理,本文部分文字与图片资源来自于网络,转载此文是出于传递更多信息之目的,若有来源标注错误或侵犯了您的合法权益,请立即通知我们,情况属实,我们会第一时间予以删除,并同时向您表示歉意,谢谢!

我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2023 成都空麓科技有限公司

ICP备案号:蜀ICP备2023000828号-2