You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. `json-c` {#mainpage}
  2. ========
  3. JSON-C - A JSON implementation in C
  4. -----------------------------------
  5. Build Status
  6. * [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/json-c/json-c?branch=master&svg=true)](https://ci.appveyor.com/project/hawicz/json-c)
  7. * [![Travis Build Status](https://travis-ci.org/json-c/json-c.svg?branch=master)](https://travis-ci.org/json-c/json-c)
  8. JSON-C implements a reference counting object model that allows you to easily
  9. construct JSON objects in C, output them as JSON formatted strings and parse
  10. JSON formatted strings back into the C representation of JSON objects.
  11. It aims to conform to [RFC 7159](https://tools.ietf.org/html/rfc7159).
  12. Building on Unix with `git`, `gcc` and `autotools`
  13. --------------------------------------------------
  14. Home page for json-c: https://github.com/json-c/json-c/wiki
  15. ### Prerequisites:
  16. See also the "Installing prerequisites" section below.
  17. - `gcc`, `clang`, or another C compiler
  18. - `libtool>=2.2.6b`
  19. If you're not using a release tarball, you'll also need:
  20. - `autoconf>=2.64` (`autoreconf`)
  21. - `automake>=1.10.3`
  22. Make sure you have a complete `libtool` install, including `libtoolize`.
  23. ### Build instructions:
  24. `json-c` GitHub repo: https://github.com/json-c/json-c
  25. ```sh
  26. $ git clone https://github.com/json-c/json-c.git
  27. $ cd json-c
  28. $ sh autogen.sh
  29. ```
  30. followed by
  31. ```sh
  32. $ ./configure
  33. $ make
  34. $ make install
  35. ```
  36. To build and run the test programs:
  37. ```sh
  38. $ make check
  39. ```
  40. Linking to `libjson-c`
  41. ----------------------
  42. If your system has `pkgconfig`,
  43. then you can just add this to your `makefile`:
  44. ```make
  45. CFLAGS += $(shell pkg-config --cflags json-c)
  46. LDFLAGS += $(shell pkg-config --libs json-c)
  47. ```
  48. Without `pkgconfig`, you would do something like this:
  49. ```make
  50. JSON_C_DIR=/path/to/json_c/install
  51. CFLAGS += -I$(JSON_C_DIR)/include/json-c
  52. LDFLAGS+= -L$(JSON_C_DIR)/lib -ljson-c
  53. ```
  54. Install prerequisites
  55. -----------------------
  56. If you are on a relatively modern system, you'll likely be able to install
  57. the prerequisites using your OS's packaging system.
  58. ### Install using apt (e.g. Ubuntu 16.04.2 LTS)
  59. ```sh
  60. sudo apt install git
  61. sudo apt install autoconf automake libtool
  62. sudo apt install valgrind # optional
  63. ```
  64. Then start from the "git clone" command, above.
  65. ### Manually install and build autoconf, automake and libtool
  66. For older OS's that don't have up-to-date version of the packages will
  67. require a bit more work. For example, CentOS release 5.11, etc...
  68. ```sh
  69. curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
  70. curl -O http://ftp.gnu.org/gnu/automake/automake-1.15.tar.gz
  71. curl -O http://ftp.gnu.org/gnu/libtool/libtool-2.2.6b.tar.gz
  72. tar xzf autoconf-2.69.tar.gz
  73. tar xzf automake-1.15.tar.gz
  74. tar xzf libtool-2.2.6b.tar.gz
  75. export PATH=${HOME}/ac_install/bin:$PATH
  76. (cd autoconf-2.69 && \
  77. ./configure --prefix ${HOME}/ac_install && \
  78. make && \
  79. make install)
  80. (cd automake-1.15 && \
  81. ./configure --prefix ${HOME}/ac_install && \
  82. make && \
  83. make install)
  84. (cd libtool-2.2.6b && \
  85. ./configure --prefix ${HOME}/ac_install && \
  86. make && \
  87. make install)
  88. ```