protobuf的安装与卸载

Protobuf介绍
1、Protobuf 是一种较为灵活的数据协议,可序列化数据结构生成源代码(C++、Python等等)
2、可用于数据传输、存储。

安装系统:Ubuntu14.04

安装:
1、安装辅助包,如果确定系统上已经安装了以下库及工具则略过这一步
sudo apt-get install autoconf automake libtool curl make g++ unzip

2、获取源代码:
(1) 、到github上下载对应语言的版本
下载压缩包:
最新版:https://github.com/protocolbuffers/protobuf/releases/latest
2.5: https://github.com/protocolbuffers/protobuf/tree/v2.5.0
或者直接git clone
git clone https://github.com/protocolbuffers/protobuf.git
(git clone 会下载最新版本的,为避免下载版本错误还是直接下载压缩包)

(2) 、cd protobuf
(3) 、git submodule update --init –recursive(低版本不必运行)
(4) 、./autogen.sh

Ps:
(1) 、运行./autogen.sh的时候如果提示: autoreconf not found
运行以下命令:sudo apt-get install autoconf automake libtool 安装依赖工具

(2) 、低版本的protobuf,比如2.5运行autogen.sh会下载googletest-1.5.0,但是因为google被墙了所以只能手动下载googletest
地址:https://github.com/google/googletest/tree/release-1.5.0
下载后解压放到protobuf文件当中并改名为:gtest,然后继续运行./autogen.sh就行

(3) 、运行./autogen.sh的目的是生成configuer可执行文件

3、安装
(1) ./configure 配置安装地址
(2) make 编译
(3) make check 检查编译结果
(4) sudo make install 安装
(5) sudo ldconfig 刷新系统库路径

Ps: If “make check” fails, you can still install, but it is likely that some features of this library will not work correctly on your system.
如果make check 步骤中有提示fails,依旧可以安装,但是有可能部分库功能不能正常运行

运行:
使用protoc 命令根据 proto文件生成.h、.cc文件
e.g:protoc --cpp_out=./ test.proto

卸载:
物理人工删除,把以下文件夹及库文件删除即可
/usr/local/bin/protoc 执行文件
/usr/local/include/google 头文件
/usr/local/lib/libproto* (*表示可被任意字符替代) 库文件

有错的地方欢迎指出来 O(∩_∩)O~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值