Mac M1(Apple Silicon) 安装 protobuf 2.5.0
因为项目中的protobuf是2.5.0版本,但是旧版本的protobuf 不支持M1,此时需要修改源码重新编译操作步骤:
从git上面下载对应版本的protobuf,地址:Release Protocol Buffers v2.5.0 · protocolbuffers/protobuf · GitHub解压进入src/google/protobuf/stubs/这个目录下,编辑platform_macros.h找到以下代码
#else#error Host architecture was not detected as supported by protobuf在上面增加
#elif defined(__arm64__)#define GOOGLE_PROTOBUF_ARCH_ARM 1#define GOOGLE_PROTOBUF_ARCH_64_BIT 1
最终结果如下图
platform_macros.h.png
在源码根目录下执行(****/protobuf-2.5.0/)
./configuremakemake checkmake install
[*]验证
执行下面检查protoc命令是否存在
which protoc注意事项
下载红框里的tag版本后重新编译,不是下载source code哦
not source code.png
参考链接
GitLab · issues · 8836
附 brew 安装 protobuf 2.5.0
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/0f0b2fc5e2541712b0bb06f74cc1559b1c884750/Formula/protobuf@2.5.rb作者:tison链接:https://www.zhihu.com/question/360006055/answer/928011185来源:知乎著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
页:
[1]