温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何解决C#版Nebula客户端编译的问题

发布时间:2021-07-21 13:52:02 来源:亿速云 阅读:170 作者:小新 栏目:开发技术

小编给大家分享一下如何解决C#版Nebula客户端编译的问题,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

一、需求背景

从Nebula的Github上可以发现,Nebula为以下语言提供了客户端SDK:

nebula-cpp
nebula-java
nebula-go
nebula-python
nebula-node
nebula-rust

我们公司的业务开发语言是C#,但Nebula却没有提供C#版的客户端。

由于Nebula支持源码编译,索性只好尝试动手编译一个。

二、Thrift简介

1.Thrift是Facebook在2007年贡献给Apache基金会的一个开源项目:https://thrift.apache.org/

Thrift可以支持多种程序语言,例如:C++,C#,Cocoa,Erlang,Haskell,Java,Ocami,Perl,PHP,Python,Ruby,Smalltalk。

Thrift可以作为二进制的高性能的通讯中间件,支持数据(对象)序列化和多种类型的RPC服务

2.Facebook自己也维护了一个Thrift,目前已经和Apache的Thrift差别较大,重写了编译器,重新实现了一个全异步的Thrift Server:https://github.com/facebook/fbthrift

Facebook Thrift is not a distribution of Apache Thrift.
This is an evolved internal branch of Thrift that Facebook re-released to open source community in February 2014.
Facebook Thrift was originally released closely tracking Apache Thrift but is now evolving in new directions.
In particular, the compiler was rewritten from scratch and the new implementation features a fully asynchronous Thrift server.

3.Nebula的客户端基于Thrift文件进行编译的,但是使用的Thrift编译器,不是Facebook贡献给Apache的那个Thrift,而是Facebook自己维护的那个Thrift,有点绕。

4.Nebula提供的Thrift模板为:https://github.com/vesoft-inc/nebula-common/tree/master/src/common/interface

如何解决C#版Nebula客户端编译的问题

三、编译前准备工作

1.操作系统

通过VMware搭建的本地CenOS 7,虚拟机与主机健通过NAT网络连接,内存8G,宿主机有梯子可以FQ

如何解决C#版Nebula客户端编译的问题

2.安装依赖

root# yum update
root# yum install -y make \
                 m4 \
                 git \
                 wget \
                 unzip \
                 xz \
                 readline-devel \
                 ncurses-devel \
                 zlib-devel \
                 gcc \
                 gcc-c++ \
                 cmake \
                 gettext \
                 curl \
                 redhat-lsb-core \
                 bzip2

3.检查主机上的GCC和CMake版本是否正确

root# g++ --version
root# cmake --version

发现版本不正确,并且git clone也不好使,只好手动下载2.0.1版本的nebula-common:https://github.com/vesoft-inc/nebula-common/tree/v2.0.1

如何解决C#版Nebula客户端编译的问题

4.解压上述的nebula-common-2.0.1.zip解压,进入nebula-common-2.0.1根目录

如何解决C#版Nebula客户端编译的问题

5.依次执行如下命令

// 安装CMake。
root# ./third-party/install-cmake.sh cmake-install

// 启用CMake。
root# source cmake-install/bin/enable-cmake.sh

//opt目录添加写权限。
root# sudo mkdir /opt/vesoft && sudo chmod -R a+w /opt/vesoft

// 安装GCC。安装到opt目录需要写权限,用户也可以修改为其他目录。
root# ./third-party/install-gcc.sh --prefix=/opt

// 启用GCC。
root# source /opt/vesoft/toolset/gcc/7.5.0/enable

// 安装第三方依赖
root# ./third-party/install-third-party.sh

四、编译

1.进入上述的nebula-common-2.0.1根目录

2.依次执行命令

root#cmake
root#make

3.查看基于Thrift模板生成的C#代码

nebula-common-2.0.1/src/common/interface/gen-csharp/nebula

如何解决C#版Nebula客户端编译的问题

以上是“如何解决C#版Nebula客户端编译的问题”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI