什么時(shí)候需要安裝
如果使用 protoc 命令,遇到 Protoc not found,表示未安裝。或者,執(zhí)行時(shí)出現(xiàn)錯(cuò)誤:This parser only recognizes "proto2",則表示不是3.0版。
安裝過(guò)程及可能遇到的問(wèn)題
安裝指令
詳細(xì)介紹請(qǐng)參考此文:protobuf簡(jiǎn)單介紹和ubuntu 16.04環(huán)境下安裝
依次執(zhí)行以下命令,下載源碼編譯安裝,需要較長(zhǎng)時(shí)間,超過(guò)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.
可能遇到問(wèn)題
很有可能,執(zhí)行過(guò)程中會(huì)出現(xiàn)以下錯(cuò)誤提示:
./autogen.sh: 4: ./autogen.sh: autoreconf: not found
解決辦法:執(zhí)行以下命令即可。
sudo apt-get install autoconf
sudo apt-get install automake
sudo apt-get install libtool
安裝完成之后
執(zhí)行以下命令驗(yàn)證安裝結(jié)果,查看版本號(hào)。
protoc --version
恭喜得到:libprotoc 3.9.0 或更高版本號(hào)。
總結(jié)
以上所述是小編給大家介紹的在 Ubuntu 上安裝 Protobuf 3 的教程,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺(jué)得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!