最近项目需要使用google 的protocol buffers,就看了下protobuf相关内容,发现网上中文资料大多停留在protobuf2阶段,经查阅protobuf已经更新到3.11.4版本了,并且3系列比2优化的内容更多,使用也更方便。下面记录下从下载源码,编译protobuf库,到测试使用。
1.安装protobuf3.11.4
1.1 解决编译protobuf库文件工具
如果你已经成功在centos下安装了Qt,并可以正常执行编译运行程序,此步骤不需要。
yum -y install autoconf automake libtool curl make g++ unzip
1.2 下载源码并安装
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh
./configure
make
make check
make install # root
ldconfig # refresh shared library cache.
安装库中出现的问题:
我自己第一次编译protobuf源码的时候,没有clone子模块,
即recursive,在执行make check的时候报错了,如下图:

在报错的情况下,依然执行了make install, 库安装成功了。
but but 后来在看官方文档的时候,发现了这样一句话:If “make c

本文记录了在CentOS8.1系统中安装protobuf3.11.4的详细过程,包括解决编译工具问题、下载源码并安装,以及在遇到错误时如何正确操作。在首次安装时由于未克隆子模块导致`make check`失败,但仍然进行了`make install`,并在查阅官方文档后决定重新编译安装,确保库功能的正确性。最终成功安装protobuf3.11.4,库位于/usr/local/lib。
最低0.47元/天 解锁文章
1446





