天天看點

Ubuntu —— 庫安裝 :: protobuf方法一:方法二:

  • Prerequesites

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

  • Installation

    From this page, download the protobuf-all-[VERSION].tar.gz.

    Extract the contents and change in the directory

./configure
make
make check
sudo make install
sudo ldconfig # refresh shared library cache.
           
  • Check if it works
$ protoc --version
libprotoc 3.6.1
           

轉載連接配接:

方法一連結:https://www.cnblogs.com/herd/p/10888267.html

方法二連結:https://www.jianshu.com/p/6bf604c9748a

方法一:

  1. 下載下傳安裝包
git clone https://github.com/protocolbuffers/protobuf.git
           
  1. 安裝需要用到的工具
sudo apt-get install autoconf automake libtool curl make g++ unzip
           
  1. 檢視下載下傳的檔案
ls
           
cd protobuf
           
ls

appveyor.bat  compiler_config_setting.bzl  docs                          js           post_process_dist.sh  python       update_file_lists.sh
appveyor.yml  composer.json                editors                       kokoro       protobuf.bzl          README.md    update_version.py
autogen.sh    configure.ac                 examples                      LICENSE      protobuf_deps.bzl     ruby         util
benchmarks    conformance                  generate_changelog.py         m4           protobuf-lite.pc.in   six.BUILD    WORKSPACE
BUILD         CONTRIBUTING.md              generate_descriptor_proto.sh  Makefile.am  protobuf.pc.in        src
CHANGES.txt   CONTRIBUTORS.txt             global.json                   objectivec   Protobuf.podspec      tests.sh
cmake         csharp                       java                          php          protoc-artifacts      third_party
           
  1. 更新子子產品
git submodule update --init --recursive
           
ls
appveyor.bat  compiler_config_setting.bzl  docs                          js           post_process_dist.sh  python       update_file_lists.sh
appveyor.yml  composer.json                editors                       kokoro       protobuf.bzl          README.md    update_version.py
autogen.sh    configure.ac                 examples                      LICENSE      protobuf_deps.bzl     ruby         util
benchmarks    conformance                  generate_changelog.py         m4           protobuf-lite.pc.in   six.BUILD    WORKSPACE
BUILD         CONTRIBUTING.md              generate_descriptor_proto.sh  Makefile.am  protobuf.pc.in        src
CHANGES.txt   CONTRIBUTORS.txt             global.json                   objectivec   Protobuf.podspec      tests.sh
cmake         csharp                       java                          php          protoc-artifacts      third_party
           
  1. 配置及安裝
./autogen.sh
           
./configure
           
make
           
make check
           
sudo make install
           
sudo ldconfig
           
protoc --version
           

方法二:

google protobuf 安裝方法:

下載下傳:

打開網頁

https://github.com/google/protobuf/releases

Ubuntu —— 庫安裝 :: protobuf方法一:方法二:

編譯安裝流程

(注意加上sudo防止建立目錄權限不足):

unzip protobuf-all-3.6.0.zip -d protobuf

cd protobuf-all-3.6.0

./autogen.sh

./configure --prefix=/usr/local/protobuf
           
sudo make -j8 && sudo make install
ldconfig
           

環境變量配置:

sudo gedit ~/.bashrc
           

添加: PATH=/usr/local/protobuf/bin:$PATH

(如果findpackage報錯注意添加lib和include到環境變量)

source ~/.bashrc

參考:

https://www.cnblogs.com/darkknightzh/p/5782992.html