安装Protobuf
CentOS操作系统
- 安装Protobuf。
1
yum install -y protobuf protobuf-devel
- 验证Protobuf是否安装成功。
1
protoc --version
回显如下所示即为安装成功。
- 将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 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
- 将解压后的目录移至“/opt/tools/installed/”目录。
1
mv protobuf-2.5.0 /opt/tools/installed/
- 进入“/opt/tools/installed/”目录。
1
cd /opt/tools/installed
- 下载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/
- 进入“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
父主题: 配置编译环境