安装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版本,没有可安装版本,所以使用下面方法安装。

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

备注:

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

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

#原文 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安装方式。

 

原文链接: https://www.cnblogs.com/xiaopan-cp9/p/10868978.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    安装protobuf

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/295186

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月15日 下午4:39
下一篇 2023年2月15日 下午4:39

相关推荐