什麼時候需要安裝 如果使用 protoc 命令,遇到 Protoc not found ,表示未安裝。或者,執行時出現錯誤: This parser only recognizes "proto2" ,則表示不是3.0版。 安裝過程及可能遇到的問題 安裝指令 詳細介紹請參考此文: "protobuf ...
什麼時候需要安裝
如果使用 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 或更高版本號。