linux安装protoc

protobuf 是做什么的?

专业的解答:
Protocol Buffers 是一种轻便高效的结构化数据存储格式,可用于结构化数据串行化,很适合做数据存储或 RPC 数据交换格式。它可用于通讯协议、数据存储等领域的语言无关、平台无关、可扩展的序列化结构数据格式。简单的说就是干和xml一样的事,把某种数据结构的信息,以某种格式保存起来。主要用于数据存储、传输协议格式等场合

protobuf 的优缺点

protobuf 如何安装?

下载安装包

下载地址
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

安装完成!

原文地址:https://www.cnblogs.com/niuben/p/14212878.html