Java教程

ubuntu 16 安装protobuf

本文主要是介绍ubuntu 16 安装protobuf,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
$ sudo apt-get install autoconf automake libtool curl make g++ unzip
$ git clone https://github.com/google/protobuf.git
$ cd protobuf
$ git submodule update --init --recursive
$ ./autogen.sh
$ ./configure
$ make
$ make check
$ sudo make install
$ sudo ldconfig # refresh shared library cache.
————————————————
版权声明:本文为CSDN博主「宛十八」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/kdchxue/article/details/81046192

protobuf在ubuntu 下安装 【版本16.04】

官方地址:https://github.com/google/protobuf/blob/master/src/README.md

C++ Installation - Unix

To build protobuf from source, the following tools are needed:

  • autoconf
  • automake
  • libtool
  • make
  • g++
  • unzip

On Ubuntu/Debian, you can install them with:

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

On other platforms, please use the corresponding package managing tool to install them before proceeding.

To get the source, download one of the release .tar.gz or .zip packages in the release page:

https://github.com/protocolbuffers/protobuf/releases/latest

For example: if you only need C++, download protobuf-cpp-[VERSION].tar.gz; if you need C++ and Java, download protobuf-java-[VERSION].tar.gz (every package contains C++ source already); if you need C++ and multiple other languages, download protobuf-all-[VERSION].tar.gz.

You can also get the source by "git clone" our git repository. Make sure you have also cloned the submodules and generated the configure script (skip this if you are using a release .tar.gz or .zip package):

git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh

To build and install the C++ Protocol Buffer runtime and the Protocol Buffer compiler (protoc) execute the following:

 ./configure
 make
 make check
 sudo make install
 sudo ldconfig # refresh shared library cache.

先执行

$$git checkout v2.6.1

后执行

$git submodule update --init --recursive

 不然将出现下面这些提示

Submodule 'third_party/benchmark' (https://github.com/google/benchmark.git) registered for path 'third_party/benchmark'
Submodule 'third_party/googletest' (https://github.com/google/googletest.git) registered for path 'third_party/googletest'
Cloning into 'third_party/benchmark'...
fatal: unable to access 'https://github.com/google/benchmark.git/': gnutls_handshake() failed: Error in the pull function.
fatal: clone of 'https://github.com/google/benchmark.git' into submodule path 'third_party/benchmark' failed

 执行下面这句如果出现以下情况需要修改autogen.sh

$./autogen.sh
将这段:

echo "Google Test not present.  Fetching gtest-1.5.0 from the web..."
 
curl http://googletest.googlecode.com/files/gtest-1.5.0.tar.bz2 | tar jx
 
mv gtest-1.5.0 gtest
修改为:

wget https://github.com/google/googletest/archive/release-1.5.0.tar.gz
tar xzvf release-1.5.0.tar.gz  #发现下载的文件没有后缀名,所以我改成tar xzvf release-1.5.0
mv googletest-release-1.5.0 gtest
————————————————
版权声明:本文为CSDN博主「bandaoyu」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/bandaoyu/article/details/88549426

 

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:02:06 --:--:--     0curl: (7) Failed to connect to googletest.googlecode.com port 80: Connection timed out

bzip2: Compressed file ends unexpectedly;
    perhaps it is corrupted?  *Possible* reason follows.
bzip2: Inappropriate ioctl for device
    Input file = (stdin), output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

tar: Child returned status 2
tar: Error is not recoverable: exiting now

如果没有安装 autoconf automake libtool

 $apt-get install autoconf automake libtool

————————————————
版权声明:本文为CSDN博主「_念」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/m0_37786046/article/details/76849901

将出现以下错误
 

+ sed -i -e s/RuntimeLibrary="5"/RuntimeLibrary="3"/g;
           s/RuntimeLibrary="4"/RuntimeLibrary="2"/g; gtest/msvc/gtest-md.vcproj gtest/msvc/gtest.vcproj gtest/msvc/gtest_main-md.vcproj gtest/msvc/gtest_main.vcproj gtest/msvc/gtest_prod_test-md.vcproj gtest/msvc/gtest_prod_test.vcproj gtest/msvc/gtest_unittest-md.vcproj gtest/msvc/gtest_unittest.vcproj
+ autoreconf -f -i -Wall,no-obsolete
./autogen.sh: 41: ./autogen.sh: autoreconf: not found

参考自

https://blog.csdn.net/m0_37786046/article/details/76849901 https://blog.csdn.net/bandaoyu/article/details/88549426    https://blog.csdn.net/kdchxue/article/details/81046192

这篇关于ubuntu 16 安装protobuf的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!