下载安装包

下载地址
1、首先确定自己当前linux版本(当前版本为x86_64)

复制代码

uname -a
Linux localhost.localdomain 3.10.0-1127.el7.x86_64 #1 SMP Tue Mar 31 23:36:51 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

2、选择相应的版本下载并解压到当前目录

复制代码

wget https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-x86_64.zip

unzip protoc-3.14.0-linux-x86_64.zip

3、安装 protoc
解压protoc压缩包后,可以看到 readme.txt文件

复制代码

Protocol Buffers - Google's data interchange format
Copyright 2008 Google Inc.
https://developers.google.com/protocol-buffers/

This package contains a precompiled binary version of the protocol buffer
compiler (protoc). This binary is intended for users who want to use Protocol
Buffers in languages other than C++ but do not want to compile protoc
themselves. To install, simply place this binary somewhere in your PATH.

If you intend to use the included well known types then don't forget to
copy the contents of the 'include' directory somewhere as well, for example
into '/usr/local/include/'.

Please refer to our official github site for more installation instructions:
  https://github.com/protocolbuffers/protobuf

大致意思是安装protoc,只需将bin目录下的二进制文件放在某个位置就行,如果你打算用其中的包含的其他类型,同时需要将include目录的内容也复制到某个地方,例如输入/usr/local/include/

我们把protoc放在/usr/local/bin可执行程序目录中,这样全局都可以访问到,同时把include目录的内容也复制到/usr/local/include/

复制代码

# 移动安装proto (cd到解压目录bin中后执行)
mv proto /usr/local/bin

# 把`include`目录的内容复制(cd到解压目录include中后执行)
cp google /usr/local/include

复制代码

protoc --version
libprotoc 3.14.0

安装完成!

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐