7 Compiling and Installing Jansson
8 ================================
10 The Jansson source is available at
11 http://www.digip.org/jansson/releases/.
16 Unpack the source tarball and change to the source directory:
20 bunzip2 -c jansson-|release|.tar.bz2 | tar xf -
23 The source uses GNU Autotools (autoconf_, automake_, libtool_), so
24 compiling and installing is extremely simple::
31 To change the destination directory (``/usr/local`` by default), use
32 the ``--prefix=DIR`` argument to ``./configure``. See ``./configure
33 --help`` for the list of all possible installation options. (There are
34 no options to customize the resulting Jansson binary.)
36 The command ``make check`` runs the test suite distributed with
37 Jansson. This step is not strictly necessary, but it may find possible
38 problems that Jansson has on your platform. If any problems are found,
41 If you obtained the source from a Git repository (or any other source
42 control system), there's no ``./configure`` script as it's not kept in
43 version control. To create the script, the build system needs to be
44 bootstrapped. There are many ways to do this, but the easiest one is
45 to use ``autoreconf``::
49 This command creates the ``./configure`` script, which can then be
50 used as described above.
52 .. _autoconf: http://www.gnu.org/software/autoconf/
53 .. _automake: http://www.gnu.org/software/automake/
54 .. _libtool: http://www.gnu.org/software/libtool/
60 On Windows and other non Unix-like systems, you may be unable to run
61 the ``./configure`` script. In this case, follow these steps. All the
62 files mentioned can be found in the ``src/`` directory.
64 1. Create ``jansson_config.h``. This file has some platform-specific
65 parameters that are normally filled in by the ``./configure``
68 - On Windows, rename ``jansson_config.h.win32`` to ``jansson_config.h``.
70 - On other systems, edit ``jansson_config.h.in``, replacing all
71 ``@variable@`` placeholders, and rename the file to
74 2. Make ``jansson.h`` and ``jansson_config.h`` available to the
75 compiler, so that they can be found when compiling programs that
78 3. Compile all the ``.c`` files (in the ``src/`` directory) into a
79 library file. Make the library available to the compiler, as in
83 Building the Documentation
84 --------------------------
86 (This subsection describes how to build the HTML documentation you are
87 currently reading, so it can be safely skipped.)
89 Documentation is in the ``doc/`` subdirectory. It's written in
90 reStructuredText_ with Sphinx_ annotations. To generate the HTML
91 documentation, invoke::
95 and point your browser to ``doc/_build/html/index.html``. Sphinx_ 1.0
96 or newer is required to generate the documentation.
98 .. _reStructuredText: http://docutils.sourceforge.net/rst.html
99 .. _Sphinx: http://sphinx.pocoo.org/
102 Compiling Programs that Use Jansson
103 ===================================
105 Jansson involves one C header file, :file:`jansson.h`, so it's enough
112 in the beginning of every source file that uses Jansson.
114 There's also just one library to link with, ``libjansson``. Compile and
115 link the program as follows::
117 cc -o prog prog.c -ljansson
119 Starting from version 1.2, there's also support for pkg-config_::
121 cc -o prog prog.c `pkg-config --cflags --libs jansson`
123 .. _pkg-config: http://pkg-config.freedesktop.org/