安裝 protobuf


一、下載protobuf

方法一:===> git clone https://github.com/protocolbuffers/protobuf.git

方法二:===> 或者將准備好的壓縮包進行拖入
解壓
Unzip protobuf1.zip

 

二、安裝(Linux Ubuntu)
(1)安裝依賴工具
$ sudo apt-get install autoconf automake libtool curl make g++ unzip libffi-dev -y

(2)進入protobuf文件
cd protobuf/

(3)進行安裝檢測 並生成自動安裝腳本
./autogen.sh
./configure

(4)進行編譯C代碼
make

(5)進行安裝
sudo make install

(6)刷新linux共享庫關系
sudo ldconfig

 

三、測試protobuf編譯工具
protoc -h
如果正常輸出 相關指令 沒有報任何error,為安裝成功

 

四、獲取 golang語言的proto包

(1)下載
方法一:===> go get -v -u github.com/golang/protobuf/proto
方法二:===>或者將 github.com-golang-protobuf.zip拖入 進行解壓到 $GOPATH/src/github.com/golang

(2)進入到文件夾內進行編譯
$ cd $GOPATH/src/github.com/golang/protobuf/protoc-gen-go/
$ go build

(3)將生成的 protoc-gen-go可執行文件,放在/bin目錄下
$ sudo cp protoc-gen-go /bin/


免責聲明!

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



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