Mac M1安装protobuf-2.5.0

一、下载包 protobuf-2.5.0.tar.gz

https://github.com/protocolbuffers/protobuf/releases/tag/v2.5.0

二、解压包并修改文件platform_macros.h

./src/google/protobuf/stubs/platform_macros.h

增加下面这三行内容
#elif defined(__arm64__)
#define GOOGLE_PROTOBUF_ARCH_ARM 1
#define GOOGLE_PROTOBUF_ARCH_64_BIT 1

//定位到下面这两行
#else
#error Host architecture was not detected as supported by protobuf

三、安装命令

./configure //默认安装到/usr/local

make

make check

sudo make install

protoc --version //查看是否安装成功

四、卸载

$ which protoc
  /usr/local/bin/protoc
$ sudo rm /usr/local/bin/protoc

你可能感兴趣的:(Mac M1安装protobuf-2.5.0)