编译安装protobuf
- 安装依赖包
$ sudo apt-get install autoconf automake libtool curl make g++ unzip
-
可以选择直接下载release文件或是git源代码编译
- 下载地址:
需要下载protobuf-all-[VERSION].tar.gz.
https://github.com/protocolbuffers/protobuf/releases/latest
将下载的文件解压到指定目录下
$ tar -xf protobuf-all-[VERSION].tar.gz $ cd protobuf
- git clone 源代码
执行以下命令
$ git clone https://github.com/protocolbuffers/protobuf.git $ cd protobuf $ git submodule update --init --recursive
- 下载地址:
-
编译protobuf
$ ./autogen.sh
$ ./configure
$ make
$ make check
$ sudo make install
$ sudo ldconfig # refresh shared library cache.
测试是否编译成功
protoc --version
- 安装Python版本
官方教程
测试是否安装成功$ cd python $ python setup.py build $ python setup.py test $ python setup.py install
python import google.protobuf