安装protobuf

准备

#mac 确保安装了 gcc+ gcc-c++
brew install automake
brew install libtool

#centos
yum -y install gcc+ gcc-c++
yum install automake
yum install libtool

1. mac 环境

1.1 使用brew安装

brew install protobuf

此方法安装的protobuf 目前版本是3.7 比较新,若是想安装低版本,能够先执行 brew search protobuf ,搜索可安装版本,而后安装相应版本便可。因为我须要安装2.5版本,没有可安装版本,因此使用下面方法安装。c++

1.2 tar.gz安装

wget https://github.com/protocolbuffers/protobuf/archive/v2.5.0.tar.gz
tar -zxf v2.5.0.tar.gz 
cd protobuf-2.5.0
./autogen.sh
./configure --prefix=/opt/protobuf-2.5.0
make
make install

备注:git

下载tar包地址我使用的是GitHub地址,网上有提供 http://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz 地址,我没法下载,不知道是个例仍是资源已经没法下载了。github

执行 ./autogen.sh 会遇到,没法下载谷歌的gtest卡在那里。解决方式就是修改 autogen.sh脚本。web

#原文 22 23行删除 21 echo "Google Test not present. Fetching gtest-1.5.0 from the web..."
22 curl http:
//googletest.googlecode.com/files/gtest-1.5.0.tar.bz2 | tar jx 23 mv gtest-1.5.0 gtest
#替换下面内容,这里采用 wget 命令下载,使用1.5版本是由于原文 21 行,地址若是有错误请使用GitHub上的下载地址
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

2.centos环境

安装相似于mac环境tar.gz安装方式。centos

相关文章
相关标签/搜索