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.
————————————————
版权声明:本文为优快云博主「宛十八」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/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
————————————————
版权声明:本文为优快云博主「bandaoyu」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/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

————————————————
版权声明:本文为优快云博主「_念」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/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.youkuaiyun.com/m0_37786046/article/details/76849901 https://blog.youkuaiyun.com/bandaoyu/article/details/88549426    https://blog.youkuaiyun.com/kdchxue/article/details/81046192

### 回答1: 很高兴能够回答您的问题,Ubuntu安装Protobuf的步骤如下:1. 确保安装了Git,GCC,和Make;2. 使用Git下载Protobuf的源代码;3. 进入Protobuf的源代码目录,使用./configure配置Protobuf;4. 使用make编译Protobuf;5. 使用make install安装Protobuf。 ### 回答2: 在Ubuntu安装protobuf可以按照以下步骤进行操作: 1. 打开终端,使用以下命令更新软件包列表:sudo apt update 2. 确保GCC编译器已安装,可以使用以下命令检查是否已安装:gcc --version 3. 如果GCC未安装,可以使用以下命令进行安装:sudo apt-get install build-essential 4. 使用以下命令安装protobuf软件包:sudo apt-get install protobuf-compiler 5. 安装完成后,可以使用以下命令检查所安装protobuf版本:protoc --version 6. 如果还需要安装protobuf的Python插件,在终端中运行以下命令:sudo apt-get install python-protobuf 7. 安装完成后,可以使用pip命令安装protobuf库的Python包:pip install protobuf 8. 如果需要使用其他语言的protobuf库,可以在相应语言的包管理器中安装protobuf相关包。 以上步骤完成后,就可以在Ubuntu系统中使用protobuf库进行编译和使用了。安装protobuf可以让你更加方便地进行序列化和反序列化操作,加快数据传输速度。 ### 回答3: 在Ubuntu安装protobuf可以通过以下步骤进行: 1. 打开终端,在命令行中输入以下命令来更新系统软件包列表: sudo apt-get update 2. 安装protobuf编译所需的依赖项,输入以下命令: sudo apt-get install autoconf automake libtool curl make g++ unzip 3. 下载protobuf源代码文件,可以从Github上的protobuf发布页面(https://github.com/protocolbuffers/protobuf/releases)选择合适的版本,然后用wget命令下载源代码文件,例如: wget https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz 4. 解压下载的源代码文件,使用以下命令: tar -zxvf protobuf-all-3.17.3.tar.gz 5. 进入解压后的目录,输入以下命令: cd protobuf-3.17.3 6. 首先运行配置脚本,输入以下命令: ./configure 7. 编译protobuf代码,输入以下命令: make 8. 安装protobuf,输入以下命令: sudo make install 9. 安装完成后,输入以下命令来确认protobuf的版本: protoc --version 以上步骤完成后,你就成功在Ubuntu安装protobuf。你可以在终端中使用protoc命令来编译protobuf文件。希望对你有所帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值