From 638d2842e468dde37f4e3b3ae30c3634383becf9 Mon Sep 17 00:00:00 2001 From: Odboy Date: Fri, 17 Apr 2026 21:05:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(c-client):=20=E4=BF=AE=E6=AD=A3=20cJSON=20?= =?UTF-8?q?=E5=A4=B4=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84=E5=92=8C=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修正头文件引用:cjson/cJSON.h(macOS Homebrew 标准路径) - 更新 README 编译说明: - macOS: 添加 -I/usr/local/opt/cjson/include 包含路径 - Ubuntu/Debian: 使用 pkg-config 自动获取包含路径 - 移除多余的 -lcjson 链接参数(编译时不需要) --- kenaito-conf-c-client/README.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/kenaito-conf-c-client/README.md b/kenaito-conf-c-client/README.md index 491e85c..cad9d0e 100644 --- a/kenaito-conf-c-client/README.md +++ b/kenaito-conf-c-client/README.md @@ -46,17 +46,37 @@ brew install cJSON ### 2. 编译 SDK +**macOS:** + ```bash cd kenaito-conf-c-client -gcc -c main.c -o kenaito_conf.o -lcurl -lcjson +gcc -c main.c -o kenaito_conf.o -I/usr/local/opt/cjson/include -lcurl +ar rcs libkenaito_conf.a kenaito_conf.o +``` + +**Ubuntu/Debian:** + +```bash +cd kenaito-conf-c-client +gcc -c main.c -o kenaito_conf.o $(pkg-config --cflags libcjson) -lcurl ar rcs libkenaito_conf.a kenaito_conf.o ``` ### 3. 编译 Demo +**macOS:** + ```bash cd kenaito-conf-c-client-demo -gcc -o demo main.c ../kenaito-conf-c-client/main.c -lcurl -lcjson -lpthread +gcc -o demo main.c ../kenaito-conf-c-client/main.c -I/usr/local/opt/cjson/include -lcurl -lpthread +./demo +``` + +**Ubuntu/Debian:** + +```bash +cd kenaito-conf-c-client-demo +gcc -o demo main.c ../kenaito-conf-c-client/main.c $(pkg-config --cflags libcjson) -lcurl -lpthread ./demo ```