linux下Google的Protobuf安装及使用笔记
2012-12-04 11:37
726 查看
点击打开链接
protobuf
项目主页:http://code.google.com/p/protobuf/
下载: http://protobuf.googlecode.com/files/protobuf-2.4.1.tar.gz
解压后进入protobuf-2.4.1目录进行安装:
1、./configure(注:默认可能会安装在/usr/local目录下,可以加--prefix=/usr来指定安装到/usr/lib下,可以免去路径的设置,路径设置见Linux命令pkg-config)
./configure --prefix=/usr/local/protobuf
2、make
3、make check
4、make install(需要超级用户root权限)
二、使用
关于protobuf的使用,可以参考这里
1、写proto文件,定义消息具体格式。如:helloworld.proto
package lm;
message helloworld
{
required int32 id = 1;//ID
required string str = 2;//str
optional int32 opt = 3;//optional field
}
2、使用protoc来编译生成对应语言的文件
--cpp_out:表示输出c++语言使用格式,--java_out,--python_out等,其他第三方的插件:Third-Party Add-ons for Protocol Buffers
此时会生成helloworld.pb.h及helloworld.pb.cc两个文件
3、Write A message
View Code
4、Read A message
View Code
5、编译及运行
g++ -g -o Writer helloworld.pb.cc writermessage.cpp `pkg-config --cflags --libs protobuf`
g++ -g -o Reader helloworld.pb.cc Readermessage.cpp `pkg-config --cflags --libs protobuf`
protobuf
项目主页:http://code.google.com/p/protobuf/
下载: http://protobuf.googlecode.com/files/protobuf-2.4.1.tar.gz
解压后进入protobuf-2.4.1目录进行安装:
1、./configure(注:默认可能会安装在/usr/local目录下,可以加--prefix=/usr来指定安装到/usr/lib下,可以免去路径的设置,路径设置见Linux命令pkg-config)
./configure --prefix=/usr/local/protobuf
2、make
3、make check
4、make install(需要超级用户root权限)
二、使用
关于protobuf的使用,可以参考这里
1、写proto文件,定义消息具体格式。如:helloworld.proto
package lm;
message helloworld
{
required int32 id = 1;//ID
required string str = 2;//str
optional int32 opt = 3;//optional field
}
2、使用protoc来编译生成对应语言的文件
--cpp_out:表示输出c++语言使用格式,--java_out,--python_out等,其他第三方的插件:Third-Party Add-ons for Protocol Buffers
此时会生成helloworld.pb.h及helloworld.pb.cc两个文件
3、Write A message
View Code
4、Read A message
View Code
5、编译及运行
g++ -g -o Writer helloworld.pb.cc writermessage.cpp `pkg-config --cflags --libs protobuf`
g++ -g -o Reader helloworld.pb.cc Readermessage.cpp `pkg-config --cflags --libs protobuf`
相关文章推荐
- linux下Google的Protobuf安装及使用笔记
- Google的Protobuf安装及使用笔记一
- google protobuf 在Linux下安装与使用
- Google的Protobuf安装及使用笔记
- google protobuf 在Linux下安装与使用 (亲自测了一下, 确定可用!)
- 如何在Linux环境下在CodeBlock中安装使用Google Protobuf
- PHP安装Google protobuf及使用
- google protobuf在ubuntu上安装使用步骤
- linux下安装google protobuf(详细)
- Google protobuf的安装及使用
- 【JAVA】google protobuf 3.0 安装使用
- Google protobuf的安装及使用
- 深度学习Caffe实战笔记(12)Caffe 使用Python接口No module named google.protobuf.internal修复方案
- google protobuf的简介、安装和使用
- google protobuf 在Linux下使用
- Google protobuf的安装及使用
- google protobuf安装与使用
- arm-linux-gcc-4.4.3交叉编译google的protobuf。以及使用方法
- Google protobuf的安装及使用和理解
- Linux下安装Google protobuf