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

安裝完成!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM