MacM1(ARM)安装Protocol Buffers

MacM1(ARM)安装Protocol Buffers

本文目录

protobuf下载地址:https://github.com/protocolbuffers/protobuf/releases

在运行./autogen.sh./configure命令时出现"No such file or directory"错误,是因为protobuf版本或构建方式的问题

3.21之前版本安装使用configure

如果没有configure需要先运行./autogen.sh生成

  • 配置

    powershell 复制代码
    ./configure
    // ./configure --prefix=/Users/xxx/protobuf(prefix 为安装目录,可自定义)

  • 编译和安装

    powershell 复制代码
    make
    powershell 复制代码
    sudo make install
  • 验证安装

    powershell 复制代码
    protoc --version
    libprotoc 3.21.12
  • 安装位置

    powershell 复制代码
    which protoc
    /usr/local/bin/protoc
  • 配置环境变量

    powershell 复制代码
    vim ~/.zshrc
    
    export PROTOBUF=/usr/local/bin/protoc
    export PATH=$PROTOBUF/bin:$PATH
    
    source ~/.zshrc

3.22之后版本安装使用cmake

  • 运行CMake配置

    powershell 复制代码
    cmake .
  • 报错,缺少 Abseil

    powershell 复制代码
    CMake Error at third_party/utf8_range/CMakeLists.txt:31 (add_subdirectory):
      The source directory
    
        /xxx/protobuf-25.0/third_party/abseil-cpp
    
      does not contain a CMakeLists.txt file.

    https://github.com/protocolbuffers/protobuf/issues/12016

    查看官方解释:cmake/README.md,需要下载Abseil

  • abseil-cpp下载

    官方github:https://github.com/abseil/abseil-cpp/releases

    单独安装:https://abseil.io/docs/cpp/quickstart-cmake#getting-the-abseil-code

  • 将abseil-cpp内容放入/third_party/abseil-cpp/目录下即可,不需要单独安装

  • 在源码路径下开始编译

    powershell 复制代码
    cmake . -DCMAKE_CXX_STANDARD=14
    
    // -Dprotobuf_BUILD_TESTS=OFF //配置CMake以跳过测试构建
    powershell 复制代码
    cmake --build .

    可以看到当前目录下已经可以查看编译完的protoc的版本了

  • 安装

    powershell 复制代码
    sudo make install

  • 查看安装位置和全局版本

    powershell 复制代码
    which protoc
    
    protoc --version

使用编译后的版本

不需要编译,直接使用,参考:https://grpc.io/docs/protoc-installation/

  • 选择对应平台下载 protoc-<version>-<os>-<arch>.zip

  • 解压

  • 命令行查看

    powershell 复制代码
    cd /Users/xx/protoc-25.0-osx-aarch_64/bin
    
    ./protoc --version
    libprotoc 25.0

将这个包放入自定义文件夹,设置环境变量即可

相关推荐
共享家952719 小时前
linux-数据链路层
linux·网络·macos
YLAD1 天前
gnu arm toolchain中的arm-none-eabi-gdb.exe的使用方法?
arm开发
饶宇航1 天前
嵌入式硬件——ARM
arm开发
CZIDC1 天前
MacOS字体看起来比在 Windows 上更好?
macos
Cosmoshhhyyy2 天前
linux远程部署dify和mac本地部署dify
linux·运维·macos
行星0082 天前
mac 通过homebrew 安装和使用nvm
macos·npm·node.js
2501_928094652 天前
Mac电脑录屏工具 Omi录屏专家(Mac中文)
macos·mac·录屏工具·omi
森之鸟2 天前
Mac chrome浏览器下载DevEco Studio 6.0.0 Beta2失败
前端·chrome·macos
FairGuard手游加固2 天前
版本更新!FairGuard-Mac加固工具已上线!
macos