1. Download the specified version installation package https://github.com/protocolbu… , take protobuf-cpp-3.15.6.tar.gz as an example.

CD/usr/local/lib wget HTTP: / / https://github.com/protocolbuffers/protobuf/releases/download/v3.15.6/protobuf-cpp-3.15.6.tar.gz

2. Unzip the package after downloading it and enter the directory

Tar-xzvf protobuf-cpp-3.15.6.tar.gz CD protobuf-cpp-3.15.6

3. Set the compilation directory

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

4. Installation and testing

make check

5. Installation and compilation

make && make install

6. Configure environment variables

vim ~/.bash_profile

Add an environment variable at the end of the file

export PROTOBUF=/usr/local/protobuf 
export PATH=$PATH:$PROTOBUF/bin

Use the source command to make the configuration file effective

source ~/.bash_profile

7. Test according to results

protoc --version