gettingstarted.rst 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. ***************
  2. Getting Started
  3. ***************
  4. .. highlight:: c
  5. Compiling and Installing Jansson
  6. ================================
  7. The Jansson source is available at
  8. http://www.digip.org/jansson/releases/.
  9. Unix-like systems (including MinGW)
  10. -----------------------------------
  11. Unpack the source tarball and change to the source directory:
  12. .. parsed-literal::
  13. bunzip2 -c jansson-|release|.tar.bz2 | tar xf -
  14. cd jansson-|release|
  15. The source uses GNU Autotools (autoconf_, automake_, libtool_), so
  16. compiling and installing is extremely simple::
  17. ./configure
  18. make
  19. make check
  20. make install
  21. To change the destination directory (``/usr/local`` by default), use
  22. the ``--prefix=DIR`` argument to ``./configure``. See ``./configure
  23. --help`` for the list of all possible installation options. (There are
  24. no options to customize the resulting Jansson binary.)
  25. The command ``make check`` runs the test suite distributed with
  26. Jansson. This step is not strictly necessary, but it may find possible
  27. problems that Jansson has on your platform. If any problems are found,
  28. please report them.
  29. If you obtained the source from a Git repository (or any other source
  30. control system), there's no ``./configure`` script as it's not kept in
  31. version control. To create the script, the build system needs to be
  32. bootstrapped. There are many ways to do this, but the easiest one is
  33. to use ``autoreconf``::
  34. autoreconf -vi
  35. This command creates the ``./configure`` script, which can then be
  36. used as described above.
  37. .. _autoconf: http://www.gnu.org/software/autoconf/
  38. .. _automake: http://www.gnu.org/software/automake/
  39. .. _libtool: http://www.gnu.org/software/libtool/
  40. Windows
  41. -------
  42. Jansson can be built with Visual Studio 2010 (and probably newer
  43. versions, too). The solution and project files are in the
  44. ``win32/vs2010/`` directory in the source distribution.
  45. Other Systems
  46. -------------
  47. On non Unix-like systems, you may be unable to run the ``./configure``
  48. script. In this case, follow these steps. All the files mentioned can
  49. be found in the ``src/`` directory.
  50. 1. Create ``jansson_config.h`` (which has some platform-specific
  51. parameters that are normally filled in by the ``./configure``
  52. script). Edit ``jansson_config.h.in``, replacing all ``@variable@``
  53. placeholders, and rename the file to ``jansson_config.h``.
  54. 2. Make ``jansson.h`` and ``jansson_config.h`` available to the
  55. compiler, so that they can be found when compiling programs that
  56. use Jansson.
  57. 3. Compile all the ``.c`` files (in the ``src/`` directory) into a
  58. library file. Make the library available to the compiler, as in
  59. step 2.
  60. Building the Documentation
  61. --------------------------
  62. (This subsection describes how to build the HTML documentation you are
  63. currently reading, so it can be safely skipped.)
  64. Documentation is in the ``doc/`` subdirectory. It's written in
  65. reStructuredText_ with Sphinx_ annotations. To generate the HTML
  66. documentation, invoke::
  67. make html
  68. and point your browser to ``doc/_build/html/index.html``. Sphinx_ 1.0
  69. or newer is required to generate the documentation.
  70. .. _reStructuredText: http://docutils.sourceforge.net/rst.html
  71. .. _Sphinx: http://sphinx.pocoo.org/
  72. Compiling Programs that Use Jansson
  73. ===================================
  74. Jansson involves one C header file, :file:`jansson.h`, so it's enough
  75. to put the line
  76. ::
  77. #include <jansson.h>
  78. in the beginning of every source file that uses Jansson.
  79. There's also just one library to link with, ``libjansson``. Compile and
  80. link the program as follows::
  81. cc -o prog prog.c -ljansson
  82. Starting from version 1.2, there's also support for pkg-config_::
  83. cc -o prog prog.c `pkg-config --cflags --libs jansson`
  84. .. _pkg-config: http://pkg-config.freedesktop.org/
粤ICP备19079148号