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 2.8 kB

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