Home » Linux Host, Ubuntu, SysAdmin » Commands and Packages » How to compile JSON-C – JSON implementation in C ?

How to compile JSON-C – JSON implementation in C ?

JSON-C implements a reference counting object model that allows you to easily construct JSON objects in C, output them as JSON formatted strings and parse JSON formatted strings back into the C representation of JSON objects. It aims to conform to RFC 7159.

$ git clone git://github.com/json-c/json-c.git

Compiling latest version of json-c

Check the latest branch available using “git branch -r” command and checkout to this branch as,

$ cd json-c
$ git branch -r
$ git checkout -b json-c-0.14 origin/json-c-0.14
$ mkdir build
$ cmake -DCMAKE_INSTALL_PREFIX=build .

Above commands compiles json-c which can be installed in a “build” directory as,

$ make all test install

You can see it got compiled and installed as,

$ tree build/
build/
├── include
│ └── json-c
│     ├── arraylist.h
│     ├── debug.h
│     ├── json_config.h
│     ├── json_c_version.h
│     ├── json.h
│     ├── json_inttypes.h
│     ├── json_object.h
│     ├── json_object_iterator.h
│     ├── json_pointer.h
│     ├── json_tokener.h
│     ├── json_types.h
│     ├── json_util.h
│     ├── json_visit.h
│     ├── linkhash.h
│     └── printbuf.h
└── lib
    ├── cmake
    │ └── json-c
    │     ├── json-c-config.cmake
    │     ├── json-c-targets.cmake
    │     └── json-c-targets-debug.cmake
    ├── libjson-c.so -> libjson-c.so.5
    ├── libjson-c.so.5 -> libjson-c.so.5.0.0
    ├── libjson-c.so.5.0.0
    └── pkgconfig
        └── json-c.pc

Compiling 0.12 version and earlier versions

$ git checkout -b json-c-0.12 origin/json-c-0.12
$ mkdir build
$ sudo apt-get install libtool
$ libtoolize
$ aclocal
$ autoheader
$ ./configure --prefix=./build
$ make
$ make install

Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment