4139N/ACompiling and Installing Jansson
4139N/A================================
4139N/AThe Jansson source is available at
4139N/AUnix-like systems (including MinGW)
4139N/A-----------------------------------
4139N/AUnpack the source tarball and change to the source directory:
4139N/AThe source uses GNU Autotools (autoconf_, automake_, libtool_), so
4139N/Acompiling and installing is extremely simple::
4139N/Athe ``--prefix=DIR`` argument to ``./configure``. See ``./configure
4139N/A--help`` for the list of all possible installation options. (There are
4139N/Ano options to customize the resulting Jansson binary.)
4139N/AThe command ``make check`` runs the test suite distributed with
4139N/AJansson. This step is not strictly necessary, but it may find possible
4139N/Aproblems that Jansson has on your platform. If any problems are found,
4139N/AIf you obtained the source from a Git repository (or any other source
4139N/Acontrol system), there's no ``./configure`` script as it's not kept in
4139N/Aversion control. To create the script, the build system needs to be
4139N/Abootstrapped. There are many ways to do this, but the easiest one is
4139N/AThis command creates the ``./configure`` script, which can then be
4139N/ACMake (various platforms, including Windows)
4139N/A--------------------------------------------
4139N/AJansson can be built using CMake_. Create a build directory for an
4139N/Aout-of-tree build, change to that directory, and run ``cmake`` (or ``ccmake``,
4139N/A``cmake-gui``, or similar) to configure the project.
4139N/ASee the examples below for more detailed information.
4139N/A.. note:: In the below examples ``..`` is used as an argument for ``cmake``.
4139N/A This is simply the path to the jansson project root directory.
4139N/A In the example it is assumed you've created a sub-directory ``build``
4139N/A and are using that. You could use any path you want.
4139N/AGenerating make files on unix:
4139N/A cmake .. # or `ccmake ..` for a GUI.
4139N/ACreating Visual Studio project files from the command line:
4139N/A cmake -G "Visual Studio 10" ..
4139N/AYou will now have a *Visual Studio Solution* in your build directory.
4139N/ATo run the unit tests build the ``RUN_TESTS`` project.
4139N/AIf you prefer a GUI the ``cmake`` line in the above example can
4139N/AFor command line help (including a list of available generators)
4139N/ATo list available CMake_ settings (and what they are currently set to)
4139N/AIf you prefer using Xcode instead of make files on OSX,
4139N/Ado the following. (Use the same steps as
4139N/Afor :ref:`Unix <build-cmake-unix>`)::
4139N/ABy default the CMake_ project will generate build files for building the
4139N/Astatic library. To build the shared version use::
4139N/A cmake -DJANSSON_BUILD_SHARED_LIBS=1 ..
4139N/AChanging install directory (same as autoconf --prefix)
4139N/A""""""""""""""""""""""""""""""""""""""""""""""""""""""
4139N/AJust as with the autoconf_ project you can change the destination directory
4139N/Afor ``make install``. The equivalent for autoconfs ``./configure --prefix``
4139N/Asource root directory. The configuration header file is located in the
4139N/A``android`` directory in the source distribution.
4139N/AOn non Unix-like systems, you may be unable to run the ``./configure``
4139N/Ascript. In this case, follow these steps. All the files mentioned can
4139N/Abe found in the ``src/`` directory.
4139N/A parameters that are normally filled in by the ``./configure``
4139N/A compiler, so that they can be found when compiling programs that
4139N/A3. Compile all the ``.c`` files (in the ``src/`` directory) into a
4139N/A library file. Make the library available to the compiler, as in
4139N/A(This subsection describes how to build the HTML documentation you are
4139N/Acurrently reading, so it can be safely skipped.)
4139N/ADocumentation is in the ``doc/`` subdirectory. It's written in
4139N/AreStructuredText_ with Sphinx_ annotations. To generate the HTML
4139N/Aor newer is required to generate the documentation.
4139N/ACompiling Programs that Use Jansson
4139N/A===================================
4139N/Ain the beginning of every source file that uses Jansson.
4139N/AThere's also just one library to link with, ``libjansson``. Compile and
4139N/Alink the program as follows::
4139N/AStarting from version 1.2, there's also support for pkg-config_::