鲲鹏社区首页
中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

安装Protobuf

CentOS操作系统

  1. 查询Protobuf版本。若环境的Protobuf版本不是2.5.0,请删除环境的Protobuf后再重新安装 。若环境的Protobuf版本是2.5.0,则跳过该章节。
    1
    protoc --version
    
  2. 可选:删除Protobuf。
    1
    yum remove -y protobuf protobuf-devel
    
  3. 安装Protobuf 2.5.0。
    1
    yum install -y protobuf protobuf-devel
    
  4. 验证Protobuf是否安装成功。
    1
    protoc --version
    

    回显如下所示即为安装成功。

  5. 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. 查询Protobuf版本。若环境的Protobuf版本不是2.5.0,请删除环境的Protobuf后再重新安装 。若环境的Protobuf版本是2.5.0,则跳过该章节。
    1
    protoc --version
    
  2. 可选:删除Protobuf。
    1
    yum remove -y protobuf protobuf-devel
    
  3. 查询Protobuf路径,并删除Protobuf软链接。
    1. 查询Protobuf路径。
      1
      which protoc
      

    2. 如上图所示,进入“/usr/local/bin”目录,删除“/protoc”目录。
      1
      2
      cd /usr/local/bin
      rm -rf /protoc
      
  4. 进入“/opt/tools/installed/”目录。
    1
    cd /opt/tools/installed
    
  5. 下载并解压源码。
    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. 下载protoc.zip并解压得到protoc.patch文件,其中protoc.patch存放的路径可自己指定(例如:“/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. 进入“/opt/tools/installed/protobuf-2.5.0/src/google/protobuf/stubs/”目录安装补丁。
    1
    2
    cd protobuf-2.5.0/src/google/protobuf/stubs/
    patch -p1 < protoc.patch
    
  8. 回到protobuf-2.5.0根目录,编译并安装到系统默认目录。
    1
    2
    cd /opt/tools/installed/protobuf-2.5.0
    ./autogen.sh && ./configure CFLAGS='-fsigned-char' && make -j8 && make install
    
  9. 将Protoc部署在本地Maven仓库中。
    1
    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. 重新加载环境变量。
    1
    source /etc/profile
    
  11. 检查Protobuf版本。

    若版本不是2.5.0,请重新执行安装Protobuf

    1
    protoc --version