Skip to content

Latest commit

 

History

History
111 lines (82 loc) · 3.78 KB

dependencies.md

File metadata and controls

111 lines (82 loc) · 3.78 KB

A2A C++ SDK 依赖说明

依赖分类

类别 依赖 获取方式
系统(需手动/脚本安装) OpenSSL、libcurl、libevent、nlohmann_json scripts/install_deps.sh 或系统包管理器
CMake 自动拉取 http_parser、Google Test 等 构建时 third_party/third_party.cmake(系统包优先,否则 FetchContent)
测试专用 Google Test、gcovr 启用 --with-tests / run_ut.sh 时按需安装

脚本解释器说明

scripts/ 下脚本均为 Bash(#!/usr/bin/env bash,含 set -o pipefail 等语法)。请使用 bash scripts/... 调用,勿用 sh;在 dash 等环境下 sh scripts/build.sh 会报错(如 set: Illegal option -o pipefail)。

脚本 解释器 用途
scripts/install_deps.sh bash 安装 OpenSSL、libcurl、libevent 等系统开发包
scripts/build.sh bash 配置与编译 SDK、示例、单元测试
scripts/run_ut.sh bash 运行 CTest 并生成测试/覆盖率报告
scripts/run_example.sh bash 示例冒烟测试

版本要求

依赖 最低版本 用途
C++ 编译器 C++17 语言标准
CMake 3.15 构建系统
OpenSSL 1.1.1 TLS、加密
libcurl 7.x+ HTTP Client 传输
nlohmann_json 3.11.2 JSON 序列化
libevent 2.1.12 事件循环(Server I/O)
http_parser 2.9.4 HTTP 解析
GNU coreutils — 仅 macOS:run_example.sh 超时保护(提供 gtimeout;Linux 自带 timeout)

系统包安装

一键检查与安装(推荐)

cd A2A/cpp-sdk
bash scripts/install_deps.sh

脚本会检测 Ubuntu/Debian、RHEL/CentOS/Fedora/EulerOS、Arch 等,并安装 libcurl、OpenSSL、libevent、nlohmann_json 等开发包。

Ubuntu / Debian(手动)

sudo apt-get update
sudo apt-get install -y \
  build-essential cmake \
  libssl-dev \
  libcurl4-openssl-dev \
  libevent-dev \
  nlohmann-json3-dev

CentOS / RHEL / Fedora / EulerOS(手动)

sudo yum install -y \
  gcc-c++ cmake \
  openssl-devel \
  libcurl-devel \
  libevent-devel

Arch Linux(手动)

sudo pacman -S --needed base-devel cmake openssl curl libevent nlohmann-json

macOS(Homebrew)

brew install cmake pkgconf openssl@3 curl libevent nlohmann-json coreutils

macOS 上 OpenSSL/curl 为 keg-only,CMake 会自动从 Homebrew 前缀查找它们;也可用 bash scripts/install_deps.sh 自动安装。

macOS 没有 GNU timeout,scripts/run_example.sh 的冒烟测试依赖 coreutils 提供的 gtimeout 做超时保护(找不到时会直接报错退出,不会静默取消超时)。

conda/Anaconda 环境注意:若当前 shell 激活了 conda(CONDA_PREFIX 非空),其自带的 OpenSSL/curl/libevent/nlohmann_json/GTest 等可能被 CMake 抢先选中,导致链接错误或 undefined symbols。构建前请 conda deactivate(含 base),并删除 build/ 后重新配置 (CMake 会把已找到的路径缓存进 build/CMakeCache.txt,不删缓存不生效)。

验证依赖

# OpenSSL
openssl version

# libcurl
curl-config --version

# CMake
cmake --version

# GNU timeout(macOS 为 gtimeout,来自 coreutils)
timeout --version 2>/dev/null || gtimeout --version

说明

  • 其余第三方库在首次 cmake 配置时由 third_party/third_party.cmake 处理,一般无需单独安装。
  • 若需离线构建,可预先安装上述系统包,并配置 CMake 使用系统提供的 json/libevent 等(见 A2A_USE_SYSTEM_* 选项)。
  • 从其他机器同步工程时,建议清理 third_party/*-subbuild 后再配置,避免 CMakeCache 路径不一致。