Rate This Document
Findability
Accuracy
Completeness
Readability

Installing Protobuf

CentOS

  1. Query the Protobuf version. If the Protobuf version is not 2.5.0, delete Protobuf and reinstall it. If the Protobuf version is 2.5.0, skip this section.
    protoc --version
  2. Delete Protobuf as follows:
    yum remove -y protobuf protobuf-devel
  3. Install Protobuf 2.5.0.
    1
    yum install -y protobuf protobuf-devel
    
  4. Check whether Protobuf is installed successfully.
    1
    protoc --version
    

    The installation is successful if information similar to the following is displayed:

  5. Install Maven.
    1
    mvn install:install-file -DgroupId=com.google.protobuf -DartifactId=protoc -Dversion=2.5.0 -Dclassifier=linux-aarch_64 -Dpackaging=exe -Dfile=/usr/bin/protoc
    

openEuler

  1. Query the Protobuf version. If the Protobuf version is not 2.5.0, delete Protobuf and reinstall it. If the Protobuf version is 2.5.0, skip this section.
    protoc --version
  2. Delete Protobuf as follows:
    yum remove -y protobuf protobuf-devel
  3. Query the Protobuf path and delete the Protobuf soft link.
    1. Query the Protobuf path.
      which protoc

    2. Go to the /usr/local/bin directory and delete the /protoc directory. See the preceding figure.
      cd /usr/local/bin
      rm -rf /protoc
  4. Go to the /opt/tools/installed/ directory.
    1
    cd /opt/tools/installed
    
  5. Download and decompress the source code.
    1
    2
    wget https://github.com/protocolbuffers/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz --no-check-certificate
    tar -zxf protobuf-2.5.0.tar.gz
    
  6. Download the protoc.zip package and decompress it to obtain the protoc.patch file whose storage path can be customized, for example, to /opt/tools/installed/protobuf-2.5.0/src/google/protobuf/stubs/.
    1
    2
    3
    wget https://mirrors.huaweicloud.com/kunpeng/archive/kunpeng_solution/bigdata/Patch/protoc.zip --no-check-certificate
    unzip protoc.zip
    cp ./protoc/protoc.patch ./protobuf-2.5.0/src/google/protobuf/stubs/
    
  7. Go to the /opt/tools/installed/protobuf-2.5.0/src/google/protobuf/stubs/ directory and install the patch.
    1
    2
    cd protobuf-2.5.0/src/google/protobuf/stubs/
    patch -p1 < protoc.patch
    
  8. Go back to the root directory of protobuf-2.5.0, compile the file, and install it in the default directory.
    1
    2
    cd /opt/tools/installed/protobuf-2.5.0
    ./autogen.sh && ./configure CFLAGS='-fsigned-char' && make -j8 && make install
    
  9. Deploy Protoc in the local Maven repository.
    mvn install:install-file -DgroupId=com.google.protobuf -DartifactId=protoc -Dversion=2.5.0 -Dclassifier=linux-aarch_64 -Dpackaging=exe -Dfile=/usr/local/bin/protoc
  10. Reload environment variables.
    source /etc/profile
  11. Check the Protobuf version.

    If the version is not 2.5.0, perform Installing Protobuf again.

    protoc --version