1. 下載protobuf源代碼(當前最新版本為:2.5.0)
#cd /opt
#wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
2. 解壓,編譯,安裝
#tar zxvf protobuf-2.5.0.tar.gz
#cd protobuf-2.5.0
#./configure
#make
#make check
#make install
3. 繼續安裝protobuf的python模塊(如果不用python,可跳過這一步)
#cd ./python
#python setup.py build
#python setup.py test
#python setup.py install
4. 安裝完成,驗證Linux命令
#protoc –version
5. 驗證Python模塊是否被正確安裝
#python
>>>import google.protobuf
如果沒有報錯,說明安裝正常。
Note:
error: package directory 'google/protobuf/compiler' does not exist
解決辦法:在google/protobuf/下創建compiler文件夾
再次在protobuf文件夾下運行:python setup.py install