Ubuntu下 安装Protocol Buffers 3.3.0

依赖安装

$ sudo apt-get install autoconf automake libtool curl make g++ unzip

下载

到GitHub下载https://github.com/google/protobuf/releases/下载.或用这地址下载v3.3的 https://github.com/google/protobuf/archive/v3.3.0.zip

Install Protobuf

``` shell cd protobuf-3.3.0/ $ ./autogen.sh $ ./configure $ make $ make check

```shell
============================================================================
Testsuite summary for Protocol Buffers 3.3.0
============================================================================
# TOTAL: 7
# PASS:  7
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================
$ sudo make install
$ sudo ldconfig # refresh shared library cache.

测试是否安装成功.

protoc --version

正常应该是输出

libprotoc 3.3.0

如果报错提示:

protoc: error while loading shared libraries: libprotoc.so.13: cannot open shared object file: No such file or directory

错误原因

protobuf的默认安装路径是/usr/local/lib,而/usr/local/lib不在ubuntu体系默认的LDLIBRARYPATH里,所以就找不到lib

解决办法

1 在/etc/ld.so.conf.d/目录下创建文件 bprotobuf.conf文件,文件内容如下

/usr/local/lib

2 输入命令

sudo ldconfig

这时,再输入protoc --version就可以正常看到版本号了

安装protobuf的Python模块

继续安装protobuf的Python模块

$cd ./python 
$python setup.py build 
$python setup.py test 
$python setup.py install
Installed /usr/local/lib/python2.7/dist-packages/protobuf-3.3.0-py2.7.egg
Processing dependencies for protobuf==3.3.0
Searching for setuptools==26.1.1
Best match: setuptools 26.1.1
Adding setuptools 26.1.1 to easy-install.pth file
Installing easy_install-3.5 script to /usr/local/bin
Installing easy_install script to /usr/local/bin

Using /usr/local/lib/python2.7/dist-packages
Searching for six==1.10.0
Best match: six 1.10.0
Adding six 1.10.0 to easy-install.pth file

Using /usr/local/lib/python2.7/dist-packages
Finished processing dependencies for protobuf==3.3.0

测试是否安装好

sudo python -c 'import google.protobuf;print google.protobuf.__version__'

如果正常,输出3.3.0版本号.


相关推荐


评论(0条)

暂时还没有评论,第一个来评论吧!


我要发表看法

引用   粗体   链接   缩进  

最近编辑

热门标签