安装Protobuf
CentOS操作系统
- 查询Protobuf版本。若环境的Protobuf版本不是2.5.0,请删除环境的Protobuf后再重新安装 。若环境的Protobuf版本是2.5.0,则跳过该章节。
1
protoc --version
- 可选:删除Protobuf。
1
yum remove -y protobuf protobuf-devel
- 安装Protobuf 2.5.0。
1
yum install -y protobuf protobuf-devel
- 验证Protobuf是否安装成功。
1
protoc --version
回显如下所示即为安装成功。
- 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操作系统
- 查询Protobuf版本。若环境的Protobuf版本不是2.5.0,请删除环境的Protobuf后再重新安装 。若环境的Protobuf版本是2.5.0,则跳过该章节。
1
protoc --version
- 可选:删除Protobuf。
1
yum remove -y protobuf protobuf-devel
- 查询Protobuf路径,并删除Protobuf软链接。
- 查询Protobuf路径。
1
which protoc
- 如上图所示,进入“/usr/local/bin”目录,删除“/protoc”目录。
1 2
cd /usr/local/bin rm -rf /protoc
- 查询Protobuf路径。
- 进入“/opt/tools/installed/”目录。
1
cd /opt/tools/installed
- 下载并解压源码。
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
- 下载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/
- 进入“/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
- 回到protobuf-2.5.0根目录,编译并安装到系统默认目录。
1 2
cd /opt/tools/installed/protobuf-2.5.0 ./autogen.sh && ./configure CFLAGS='-fsigned-char' && make -j8 && make install
- 将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
- 重新加载环境变量。
1
source /etc/profile
- 检查Protobuf版本。
若版本不是2.5.0,请重新执行安装Protobuf。
1
protoc --version
父主题: 配置编译环境