协议缓冲区编译器安装

Protocol Buffer Compiler Installation

协议缓冲区编译器安装

How to install the protocol buffer compiler.

如何安装协议缓冲区编译器。

While not mandatory, gRPC applications often leverage Protocol Buffers for service definitions and data serialization. Most of the example code from this site uses version 3 of the protocol buffer language (proto3).

​虽然不是强制性的,但gRPC应用程序通常利用协议缓冲区进行服务定义和数据序列化。该站点的大多数示例代码使用协议缓冲语言(proto3)的第3版。

The protocol buffer compiler, protoc, is used to compile .proto files, which contain service and message definitions. Choose one of the methods given below to install protoc.

协议缓冲区编译器protoc用于编译.proto文件,其中包含服务和消息定义。选择下面给出的方法之一来安装协议。

Install using a package manager

使用包管理器安装

You can install the protocol compiler, protoc, with a package manager under Linux or macOS using the following commands.

可以使用以下命令在Linux或macOS下使用包管理器安装协议编译器protoc。

Warning

警告

Check the version of protoc (as indicated below) after installation to ensure that it is sufficiently recent. The versions of protoc installed by some package managers can be quite dated.

安装后检查protoc的版本(如下所示),以确保其足够新。一些包管理器安装的protoc版本可能已经过时。

Installing from pre-compiled binaries, as indicated in the next section, is the best way to ensure that you’re using the latest release of protoc.

​如下一节所示,从预编译的二进制文件进行安装是确保使用最新版本的protoc的最佳方式。

  • Linux, using apt or apt-get, for example:

  • Linux,使用apt或apt-get,例如:

    $ apt install -y protobuf-compiler
    $ protoc --version  # Ensure compiler version is 3+
    
  • MacOS, using Homebrew:

  • ​MacOS,使用Homebrew:

    $ brew install protobuf
    $ protoc --version  # Ensure compiler version is 3+
    

Install pre-compiled binaries (any OS)

安装预编译的二进制文件(任何操作系统)

To install the latest release of the protocol compiler from pre-compiled binaries, follow these instructions:

​要从预编译的二进制文件中安装最新版本的协议编译器,请按照以下说明进行操作:

1.Manually download from github.com/google/protobuf/releases the zip file corresponding to your operating system and computer architecture (protoc-<version>-<os>-<arch>.zip), or fetch the file using commands such as the following:

​1.从github.com/google/protobuf/releases手动下载对应操作系统和计算机体系结构的zip文件(protoc-<version>-<os>-<arch>.zip),或者使用以下命令获取文件:

$ PB_REL="https://github.com/protocolbuffers/protobuf/releases"
$ curl -LO $PB_REL/download/v3.15.8/protoc-3.15.8-linux-x86_64.zip

2.Unzip the file under $HOME/.local or a directory of your choice. For example:

2.解压缩$HOME/.local或您选择的目录下的文件。例如:

$ unzip protoc-3.15.8-linux-x86_64.zip -d $HOME/.local

3.Update your environment’s path variable to include the path to the protoc executable. For example:

3.更新环境的路径变量,使其包含协议可执行文件的路径。例如:

$ export PATH="$PATH:$HOME/.local/bin"

Other installation options

其他安装选项

If you’d like to build the protocol compiler from sources, or access older versions of the pre-compiled binaries, see Download Protocol Buffers.

​如果想从源代码构建协议编译器,或访问预编译二进制文件的旧版本,请参阅下载协议缓冲区。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值