1. 安装依赖
sudo apt-get install git gcc clang libtool autoconf automake doxygen valgrind
一些版本要求,如果版本过低可以从github上使用源码安装。
libtool≥2.2.6bautoconf≥2.64automake≥1.13doxygen≥1.8.13
2. 安装
git clone https://github.com/json-c/json-c.git
cd json-c
sh autogen.sh
./configure
make
sudo make install
- 测试:
make check

注意
为了在make编译的过程中使用json-c,需要修改makefile的信息:
- 已经安装
pkgconfig:
CFLAGS += $(shell pkg-config --cflags json-c)
LDFLAGS += $(shell pkg-config --libs json-c)
- 未安装
pkgconfig:
JSON_C_DIR=/path/to/json_c/install
CFLAGS += -I$(JSON_C_DIR)/include/json-c
LDFLAGS+= -L$(JSON_C_DIR)/lib -ljson-c