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

安装Protobuf

CentOS操作系统

  1. 安装Protobuf。
    1
    yum install -y protobuf protobuf-devel
    
  2. 验证Protobuf是否安装成功。
    1
    protoc --version
    

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

  3. 将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/bin/protoc
    

openEuler操作系统

  1. 下载并解压源码。
    1
    2
    wget https://github.com/protocolbuffers/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz
    tar -zxf protobuf-2.5.0.tar.gz
    
  2. 将解压后的目录移至“/opt/tools/installed/”目录。
    1
    mv protobuf-2.5.0 /opt/tools/installed/
    
  3. 进入“/opt/tools/installed/”目录。
    1
    cd /opt/tools/installed
    
  4. 下载protoc.zip并解压得到protoc.patch文件,其中protoc.patch存放的路径可自己指定。
    1
    2
    3
    wget https://mirrors.huaweicloud.com/kunpeng/archive/kunpeng_solution/bigdata/Patch/protoc.zip
    unzip protoc.zip
    cp ./protoc/protoc.patch ./protobuf-2.5.0/src/google/protobuf/stubs/
    
  5. 进入“protobuf-2.5.0/src/google/protobuf/stubs/”目录安装补丁。
    1
    2
    cd protobuf-2.5.0/src/google/protobuf/stubs/
    patch -p1 < protoc.patch
    
  6. 回到protobuf-2.5.0根目录,编译并安装到系统默认目录。
    1
    2
    cd /opt/tools/installed/protobuf-2.5.0
    ./autogen.sh && ./configure CFLAGS='-fsigned-char' && make -j8 && make install
    
  7. 将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