先下载protobuf-3.6.1,再执行以下操作即可
tar zvxf protobuf-all-3.6.1.tar.gz
cd protobuf-3.6.1
./configure --prefix=/usr/local/
sudo make
sudo make check
sudo make install
问题
执行./configure --prefix=/usr/local/这条时可能会有权限问题 -bash: ./configure: Permission denied,解决如下:
chmod 777 configure
再重新执行./configure --prefix=/usr/local/
sudo make
sudo make check
执行sudo make check完后又报错
make[3]: Entering directory '/userdata/test/protobuf-3.6.1/src'
PASS: protobuf-test
PASS: protobuf-lazy-descriptor-test
PASS: protobuf-lite-test
FAIL: google/protobuf/compiler/zip_output_unittest.sh
FAIL: google/protobuf/io/gzip_stream_unittest.sh
PASS: protobuf-lite-arena-test
PASS: no-warning-test
============================================================================
Testsuite summary for Protocol Buffers 3.6.1
============================================================================
# TOTAL: 7
# PASS: 5
# SKIP: 0
# XFAIL: 0
# FAIL: 2
# XPASS: 0
# ERROR: 0
============================================================================
See src/test-suite.log
Please report to protobuf@googlegroups.com
============================================================================
make[3]: *** [Makefile:7613: test-suite.log] Error 1
make[3]: Leaving directory '/userdata/test/protobuf-3.6.1/src'
make[2]: *** [Makefile:7721: check-TESTS] Error 2
make[2]: Leaving directory '/userdata/test/protobuf-3.6.1/src'
make[1]: *** [Makefile:7834: check-am] Error 2
make[1]: Leaving directory '/userdata/test/protobuf-3.6.1/src'
make: *** [Makefile:1538: check-recursive] Error 1
有两个失败了,查看日志src/test-suite.log
.. contents:: :depth: 2
FAIL: google/protobuf/compiler/zip_output_unittest.sh
=====================================================
../test-driver: line 107: ./google/protobuf/compiler/zip_output_unittest.sh: Permission denied
FAIL google/protobuf/compiler/zip_output_unittest.sh (exit status: 126)
FAIL: google/protobuf/io/gzip_stream_unittest.sh
================================================
../test-driver: line 107: ./google/protobuf/io/gzip_stream_unittest.sh: Permission denied
FAIL google/protobuf/io/gzip_stream_unittest.sh (exit status: 126)
发现又是权限问题,解决方法如下,终端命令行输入:
chmod 777 src/google/protobuf/compiler/zip_output_unittest.sh
chmod 777 src/google/protobuf/io/gzip_stream_unittest.sh
再重新执行
sudo make check
成功
PASS: protobuf-test
PASS: protobuf-lazy-descriptor-test
PASS: protobuf-lite-test
PASS: google/protobuf/compiler/zip_output_unittest.sh
PASS: google/protobuf/io/gzip_stream_unittest.sh
PASS: protobuf-lite-arena-test
PASS: no-warning-test
============================================================================
Testsuite summary for Protocol Buffers 3.6.1
============================================================================
# TOTAL: 7
# PASS: 7
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
============================================================================
最后安装
sudo make install