Centos6.4下安装protobuf及简单使用
2013-07-24 00:57
666 查看
1、protobuf是google公司提出的数据存储格式,详细介绍可以参考:https://code.google.com/p/protobuf/
2、下载最新的protobuf,下载地址:https://code.google.com/p/protobuf/downloads/list
3、下载protobuf2.5.o版本,protobuf-2.5.0.tar.gz解压并进行安装。
解压:tar xvf protobuf-2.5.0.tar.gz
安装步骤:(1)./configure (2)make (3)make check (4)make install
注意:安装成功后,将它的bin和lib目录分别加入到PATH和LD_LIBRARY_PATH环境变量,以方便直接调用。
通常建议安装到/usr/local目录下,执行configure时,指定--prefix=/usr/local/protobuf即可
设置环境变量过程:编辑/etc/profile,在文件末尾添加:
4、测试例子:
创建一个.proto文件,文件为:x.proto
2、下载最新的protobuf,下载地址:https://code.google.com/p/protobuf/downloads/list
3、下载protobuf2.5.o版本,protobuf-2.5.0.tar.gz解压并进行安装。
解压:tar xvf protobuf-2.5.0.tar.gz
安装步骤:(1)./configure (2)make (3)make check (4)make install
注意:安装成功后,将它的bin和lib目录分别加入到PATH和LD_LIBRARY_PATH环境变量,以方便直接调用。
通常建议安装到/usr/local目录下,执行configure时,指定--prefix=/usr/local/protobuf即可
设置环境变量过程:编辑/etc/profile,在文件末尾添加:
export PATH=$PATH:/usr/local/protobuf/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/protobuf/lib
4、测试例子:
创建一个.proto文件,文件为:x.proto
1 package x; 2 message person 3 { 4 required string name = 1; 5 required int32 id = 2; 6 optional string email = 3; 7 }
编译成目标语言: protoc -I=src_dir --cpp_out=dst_dir $src_dir/addressbook.proto 5、C++语言编译命令如下: g++ -Wall -g ./dst_dir/x.pb.cc x.cpp -o x -I. -I/usr/local/protobuf/include -L/usr/local/protobuf/lib -lprotobuf -pthread 参考: http://www.ibm.com/developerworks/cn/linux/l-cn-gpb/ http://www.hadoopor.com/thread-1837-1-1.html
相关文章推荐
- Centos6.4下安装protobuf及简单使用
- Centos6.5下安装protobuf及简单使用
- Centos6.4下安装protobuf-c问题及解决办法
- Mac下安装protobuf以及简单使用
- lamp环境centos5.10,phpprotobuf模块安装,及简单应用
- CentOS 7.0 使用 yum 安装 MariaDB 与 MariaDB 的简单配置
- 简单介绍google protobuf rpc框架使用方法
- [Unity3D]简单使用Protobuf-net(三)
- Protobuf windows安装使用
- 【JAVA】google protobuf 3.0 安装使用
- CentOS 7.0 使用 yum 安装 MariaDB 与 MariaDB 的简单配置
- CentOS 7.0 使用 yum 安装 MariaDB 与 MariaDB 的简单配置
- linux下Google的Protobuf安装及使用笔记
- protobuf for python 安装与使用
- google protobuf 在Linux下安装与使用
- PHP安装Google protobuf及使用
- Google protobuf的安装及使用
- centos 6.8安装Redis和简单的使用
- [Unity3D]简单使用Protobuf-net(三)