在 Ubuntu 上安裝 Protobuf 3


什么時候需要安裝

如果使用 protoc 命令,遇到 Protoc not found,表示未安裝。或者,執行時出現錯誤:This parser only recognizes "proto2",則表示不是3.0版。

安裝過程及可能遇到的問題

安裝指令

詳細介紹請參考此文:protobuf簡單介紹和ubuntu 16.04環境下安裝
依次執行以下命令,下載源碼編譯安裝,需要較長時間,超過10分鍾。

sudo apt-get install autoconf automake libtool curl make g++ unzip
git clone https://github.com/google/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh
./configure
make
make check
sudo make install
sudo ldconfig # refresh shared library cache.

可能遇到問題

很有可能,執行過程中會出現以下錯誤提示:

./autogen.sh: 4: ./autogen.sh: autoreconf: not found

解決辦法:執行以下命令即可。

sudo apt-get install autoconf
sudo apt-get install automake
sudo apt-get install libtool

安裝完成之后

執行以下命令驗證安裝結果,查看版本號。

protoc --version

恭喜得到:libprotoc 3.9.0  或更高版本號。


免責聲明!

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



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