centos7 installation protobuf|serialization and deserialization tools

前言

那么这里博主先安利一些干货满满的专栏了!

首先是博主的高质量博客的汇总,这个专栏里面的博客,都是博主最最用心写的一部分,干货满满,希望对大家有帮助。

高质量博客汇总https://blog.csdn.net/yu_cblog/category_12379430.html?spm=1001.2014.3001.5482

What is protobuf and how to use it?

If you are interested, the blogger will open a series of explanations in the future.

installation steps

1. Download protobuf and decompress the compressed package

Installation address: https://github.com/protocolbuffers/protobuf/releases

You can choose the corresponding language according to your needs, but here I chose all, which means that all languages ​​can be used. I downloaded the version 21.12.

Then download it directly with wget, or you can download it locally and drag it to the server (virtual machine). I directly wget here.

First copy the URL of the compressed package selected, and then copy it to wget

wget https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protobuf-all-21.12.tar.gz

The URL after wget is the URL you copied.

After downloading, you must decompress the compressed package. If you downloaded zip, use unzip to decompress it. If you downloaded tar.gz, then use tar to decompress it. These are all system knowledge, so I won’t say much here , decompress directly.

I am tar.gz here so directly

tar -xvf protobuf-all-21.12.tar.gz

Don't copy the code directly, the name of the compressed package behind me may be different from yours, just adjust it yourself.

After decompression, cd into the protbuf folder.

cd protobuf-21.12

2. Install protobuf

first step

After entering the folder, you can see an autogen.sh script, run it directly.

Note: If you are not installing the version of all, but a version of a certain language, you do not need to perform this step.

./autogen.sh

second step

./configure--prefix=/usr/local/protobuf

third step

# 其实此时可以ls一下,出现了一个makefile文件的
make # 要15min左右
make check # 检查是否make好(可以跳过)也要15min左右
sudo make install # 安装

3. Modify the configuration file

To modify this file /etc/profile

So just sudo vim

sudo vim /etc/profile

I won’t teach you how to use vim here. If you don’t know how to use it, you can find it online.

Paste these things into this file.

#(动态库搜索路径)程序加载运行期间查找动态链接库时指定除了系统默认路径之外的其他路径
export LD_LIBRARY_PATH=SLD_LIBRARY_PATH:/usr/local/protobuf/lib
#(静态库搜索路径) 程序编译期间查找动态链接库时指定查找共享库的路径
export LIBRARY_PATH=SLIBRARY_PATH:/usr/local/protobuf/lib
#执行程序搜索路径
export PATH=SPATH:/usr/local/protobuf/bin/
#c程序头文件搜索路径
export C_INCLUDE_PATH=SC_INCLUDE_PATH:/usr/local/protobuf/include/
#c++程序头文件搜索路径
export CPLUS_INCLUDE_PATH=SCPLUS_INCLUDE_PATH:/usr/local/protobuf/include/
#pkg-config 路径
export PKG_CONFIG_PATH=/usr/local/protobuf/lib/pkgconfig/

Then just source it.

source /etc/profile

4. Check whether the installation is successful

protoc --version # 检查版本,看是否安装成功

If the following appears, the installation is successful 

Guess you like

Origin blog.csdn.net/Yu_Cblog/article/details/132308738