1.下载
protobuf-2.5.0.tar.gz源码上传到http://download.csdn.net/download/a493203176/9789098
2.安装
使用tar -zxf protobuf-2.5.0.tar.gz命令解压后得到是protobuf-2.5.0的源码,
cd protobuf-2.5.0 进入目录
假如你希望编译成功后输出的目录为/home/work/protobuf/ 则输入如下两条命令:
./configure --prefix=/home/work/protobuf/
make && make install
编译成功后将export PATH=/home/work/protobuf/bin:$PATH加入到环境变量中
最后输入 protoc --version命令,如显示libprotoc 2.5.0则安装成功
3. 安装protobuf c编译器(需要联网)
sudo apt-get install protobuf-c-compoler 没有网情况下 手动下载protobuf c安装包
http://download.csdn.net/download/lk1592/8980395
# ./configure CXXFLAGS=-I/home/work/protobuf/include LDFLAGS=-L/home/work/protobuf/lib
# make && make install
4.编译文件
sudo protoc-c student.proto --c_out=./test/ 说明--c_out=指定生成代码的目录
5. 如果建立一个测试工程
我测试好的工程:http://download.csdn.net/detail/a493203176/9793853
6. 测试命令(附近有我测试过的例子)
test$ gcc -o test test.c student.pb-c.c protobuf/protobuf-c