下载解压源文件
github上的版本发布地址

下载&解压&进入源码目录
当前下载protobuf2的最后一个版本
wget https://github.com/google/protobuf/archive/v2.6.1.zip
unzip v2.6.1.zip -d ./
cd protobuf-2.6.1
请根据自己的需求下载对应的版本,当前操作演示版本为protobuf2,及.proto文件中syntax = “proto2”;开头的
安装依赖
sudo apt-get install autoconf automake libtool
其他非debian发行版的机器安装对应的依赖扩展即可
生成configure文件
./autogen.sh
如果无法连接google网站
修改
curl http://googletest.googlecode.com/files/gtest-1.5.0.tar.bz2
| tar jx
mv gtest-1.5.0 gtest
为
wget https://github.com/google/googletest/archive/release-1.5.0.tar.gz
tar xzvf release-1.5.0.tar.gz
mv googletest-release-1.5.0 gtest
也可由手动删除google的连接,直接下载文件并解压
进行configure
查看帮助
./configure -h
指定安装目录
./configure prefix=/opt/protobuf2
安装
make && make install
权限不够的话,要使用sudo
在Python中的应用
使用protobuf命令生成.py文件
在PHP中的应用
使用protobuf生成.php文件
转载请注明:XAMPP中文组官网 » linux下安装protobuf及其使用