3421N/A<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3421N/A "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3421N/A
3421N/A
3421N/A<html xmlns="http://www.w3.org/1999/xhtml">
3421N/A <head>
3421N/A <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
3421N/A
3421N/A <title>Getting Started &mdash; Jansson 2.7 documentation</title>
3421N/A
3421N/A <link rel="stylesheet" href="_static/default.css" type="text/css" />
3421N/A <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
3421N/A
3421N/A <script type="text/javascript">
3421N/A var DOCUMENTATION_OPTIONS = {
3421N/A URL_ROOT: './',
3421N/A VERSION: '2.7',
3421N/A COLLAPSE_INDEX: false,
3421N/A FILE_SUFFIX: '.html',
3421N/A HAS_SOURCE: true
3421N/A };
3421N/A </script>
3421N/A <script type="text/javascript" src="_static/jquery.js"></script>
3421N/A <script type="text/javascript" src="_static/underscore.js"></script>
3421N/A <script type="text/javascript" src="_static/doctools.js"></script>
3421N/A <link rel="top" title="Jansson 2.7 documentation" href="index.html" />
3421N/A <link rel="next" title="Upgrading from 1.x" href="upgrading.html" />
3421N/A <link rel="prev" title="Jansson Documentation" href="index.html" />
3421N/A </head>
3421N/A <body>
3421N/A <div class="related">
3421N/A <h3>Navigation</h3>
3421N/A <ul>
3421N/A <li class="right" style="margin-right: 10px">
3421N/A <a href="genindex.html" title="General Index"
3421N/A accesskey="I">index</a></li>
3421N/A <li class="right" >
3421N/A <a href="upgrading.html" title="Upgrading from 1.x"
3421N/A accesskey="N">next</a> |</li>
3421N/A <li class="right" >
3421N/A <a href="index.html" title="Jansson Documentation"
3421N/A accesskey="P">previous</a> |</li>
3421N/A <li><a href="index.html">Jansson 2.7 documentation</a> &raquo;</li>
3421N/A </ul>
3421N/A </div>
3421N/A
3421N/A <div class="document">
3421N/A <div class="documentwrapper">
3421N/A <div class="bodywrapper">
3421N/A <div class="body">
3421N/A
3421N/A <div class="section" id="getting-started">
3421N/A<h1>Getting Started<a class="headerlink" href="#getting-started" title="Permalink to this headline">¶</a></h1>
3421N/A<div class="section" id="compiling-and-installing-jansson">
3421N/A<h2>Compiling and Installing Jansson<a class="headerlink" href="#compiling-and-installing-jansson" title="Permalink to this headline">¶</a></h2>
3421N/A<p>The Jansson source is available at
3421N/A<a class="reference external" href="http://www.digip.org/jansson/releases/">http://www.digip.org/jansson/releases/</a>.</p>
3421N/A<div class="section" id="unix-like-systems-including-mingw">
3421N/A<h3>Unix-like systems (including MinGW)<a class="headerlink" href="#unix-like-systems-including-mingw" title="Permalink to this headline">¶</a></h3>
3421N/A<p>Unpack the source tarball and change to the source directory:</p>
3421N/A<pre class="literal-block">
3421N/Abunzip2 -c jansson-2.7.tar.bz2 | tar xf -
3421N/Acd jansson-2.7
3421N/A</pre>
3421N/A<p>The source uses GNU Autotools (<a class="reference external" href="http://www.gnu.org/software/autoconf/">autoconf</a>, <a class="reference external" href="http://www.gnu.org/software/automake/">automake</a>, <a class="reference external" href="http://www.gnu.org/software/libtool/">libtool</a>), so
3421N/Acompiling and installing is extremely simple:</p>
3421N/A<div class="highlight-c"><div class="highlight"><pre><span class="p">.</span><span class="o">/</span><span class="n">configure</span>
3421N/A<span class="n">make</span>
3421N/A<span class="n">make</span> <span class="n">check</span>
3421N/A<span class="n">make</span> <span class="n">install</span>
3421N/A</pre></div>
3421N/A</div>
3421N/A<p>To change the destination directory (<tt class="docutils literal"><span class="pre">/usr/local</span></tt> by default), use
3421N/Athe <tt class="docutils literal"><span class="pre">--prefix=DIR</span></tt> argument to <tt class="docutils literal"><span class="pre">/configure</span></tt>. See <tt class="docutils literal"><span class="pre">/configure</span>
3421N/A<span class="pre">--help</span></tt> for the list of all possible installation options. (There are
3421N/Ano options to customize the resulting Jansson binary.)</p>
3421N/A<p>The command <tt class="docutils literal"><span class="pre">make</span> <span class="pre">check</span></tt> runs the test suite distributed with
3421N/AJansson. This step is not strictly necessary, but it may find possible
3421N/Aproblems that Jansson has on your platform. If any problems are found,
3421N/Aplease report them.</p>
3421N/A<p>If you obtained the source from a Git repository (or any other source
3421N/Acontrol system), there&#8217;s no <tt class="docutils literal"><span class="pre">/configure</span></tt> script as it&#8217;s not kept in
3421N/Aversion control. To create the script, the build system needs to be
3421N/Abootstrapped. There are many ways to do this, but the easiest one is
3421N/Ato use <tt class="docutils literal"><span class="pre">autoreconf</span></tt>:</p>
3421N/A<div class="highlight-c"><div class="highlight"><pre><span class="n">autoreconf</span> <span class="o">-</span><span class="n">vi</span>
3421N/A</pre></div>
3421N/A</div>
3421N/A<p>This command creates the <tt class="docutils literal"><span class="pre">/configure</span></tt> script, which can then be
3421N/Aused as described above.</p>
3421N/A</div>
3421N/A<div class="section" id="cmake-various-platforms-including-windows">
3421N/A<span id="build-cmake"></span><h3>CMake (various platforms, including Windows)<a class="headerlink" href="#cmake-various-platforms-including-windows" title="Permalink to this headline">¶</a></h3>
3421N/A<p>Jansson can be built using <a class="reference external" href="http://www.cmake.org">CMake</a>. Create a build directory for an
3421N/Aout-of-tree build, change to that directory, and run <tt class="docutils literal"><span class="pre">cmake</span></tt> (or <tt class="docutils literal"><span class="pre">ccmake</span></tt>,
3421N/A<tt class="docutils literal"><span class="pre">cmake-gui</span></tt>, or similar) to configure the project.</p>
3421N/A<p>See the examples below for more detailed information.</p>
3421N/A<div class="admonition note">
3421N/A<p class="first admonition-title">Note</p>
3421N/A<p class="last">In the below examples <tt class="docutils literal"><span class="pre">..</span></tt> is used as an argument for <tt class="docutils literal"><span class="pre">cmake</span></tt>.
3421N/AThis is simply the path to the jansson project root directory.
3421N/AIn the example it is assumed you&#8217;ve created a sub-directory <tt class="docutils literal"><span class="pre">build</span></tt>
3421N/Aand are using that. You could use any path you want.</p>
3421N/A</div>
3421N/A<div class="section" id="unix-make-files">
3421N/A<span id="build-cmake-unix"></span><h4>Unix (Make files)<a class="headerlink" href="#unix-make-files" title="Permalink to this headline">¶</a></h4>
3421N/A<p>Generating make files on unix:</p>
3421N/A<pre class="literal-block">
3421N/Abunzip2 -c jansson-2.7.tar.bz2 | tar xf -
3421N/Acd jansson-2.7
3421N/A
3421N/Amkdir build
3421N/Acd build
3421N/Acmake .. # or <tt class="xref c c-func docutils literal"><span class="pre">ccmake</span> <span class="pre">..()</span></tt> for a GUI.
3421N/A</pre>
3421N/A<p>Then to build:</p>
3421N/A<div class="highlight-c"><div class="highlight"><pre><span class="n">make</span>
3421N/A<span class="n">make</span> <span class="n">check</span>
3421N/A<span class="n">make</span> <span class="n">install</span>
3421N/A</pre></div>
3421N/A</div>
3421N/A</div>
3421N/A<div class="section" id="windows-visual-studio">
3421N/A<h4>Windows (Visual Studio)<a class="headerlink" href="#windows-visual-studio" title="Permalink to this headline">¶</a></h4>
3421N/A<p>Creating Visual Studio project files from the command line:</p>
3421N/A<pre class="literal-block">
3421N/A&lt;unpack&gt;
3421N/Acd jansson-2.7
3421N/A
3421N/Amd build
3421N/Acd build
3421N/Acmake -G &quot;Visual Studio 10&quot; ..
3421N/A</pre>
3421N/A<p>You will now have a <em>Visual Studio Solution</em> in your build directory.
3421N/ATo run the unit tests build the <tt class="docutils literal"><span class="pre">RUN_TESTS</span></tt> project.</p>
3421N/A<p>If you prefer a GUI the <tt class="docutils literal"><span class="pre">cmake</span></tt> line in the above example can
3421N/Abe replaced with:</p>
3421N/A<div class="highlight-c"><div class="highlight"><pre><span class="n">cmake</span><span class="o">-</span><span class="n">gui</span> <span class="p">..</span>
3421N/A</pre></div>
3421N/A</div>
3421N/A<p>For command line help (including a list of available generators)
3421N/Afor <a class="reference external" href="http://www.cmake.org">CMake</a> simply run:</p>
3421N/A<div class="highlight-c"><div class="highlight"><pre><span class="n">cmake</span>
3421N/A</pre></div>
3421N/A</div>
3421N/A<p>To list available <a class="reference external" href="http://www.cmake.org">CMake</a> settings (and what they are currently set to)
3421N/Afor the project, run:</p>
3421N/A<div class="highlight-c"><div class="highlight"><pre><span class="n">cmake</span> <span class="o">-</span><span class="n">LH</span> <span class="p">..</span>
3421N/A</pre></div>
3421N/A</div>
3421N/A</div>
3421N/A<div class="section" id="mac-osx-xcode">
3421N/A<h4>Mac OSX (Xcode)<a class="headerlink" href="#mac-osx-xcode" title="Permalink to this headline">¶</a></h4>
3421N/A<p>If you prefer using Xcode instead of make files on OSX,
3421N/Ado the following. (Use the same steps as
3421N/Afor <a class="reference internal" href="#build-cmake-unix"><em>Unix</em></a>):</p>
3421N/A<div class="highlight-c"><div class="highlight"><pre><span class="p">...</span>
3421N/A<span class="n">cmake</span> <span class="o">-</span><span class="n">G</span> <span class="s">&quot;Xcode&quot;</span> <span class="p">..</span>
3421N/A</pre></div>
3421N/A</div>
3421N/A</div>
3421N/A<div class="section" id="additional-cmake-settings">
3421N/A<h4>Additional CMake settings<a class="headerlink" href="#additional-cmake-settings" title="Permalink to this headline">¶</a></h4>
3421N/A<div class="section" id="shared-library">
3421N/A<h5>Shared library<a class="headerlink" href="#shared-library" title="Permalink to this headline">¶</a></h5>
3421N/A<p>By default the <a class="reference external" href="http://www.cmake.org">CMake</a> project will generate build files for building the
3421N/Astatic library. To build the shared version use:</p>
3421N/A<div class="highlight-c"><div class="highlight"><pre><span class="p">...</span>
3421N/A<span class="n">cmake</span> <span class="o">-</span><span class="n">DJANSSON_BUILD_SHARED_LIBS</span><span class="o">=</span><span class="mi">1</span> <span class="p">..</span>
3421N/A</pre></div>
3421N/A</div>
3421N/A</div>
3421N/A<div class="section" id="changing-install-directory-same-as-autoconf-prefix">
3421N/A<h5>Changing install directory (same as autoconf &#8211;prefix)<a class="headerlink" href="#changing-install-directory-same-as-autoconf-prefix" title="Permalink to this headline">¶</a></h5>
3421N/A<p>Just as with the <a class="reference external" href="http://www.gnu.org/software/autoconf/">autoconf</a> project you can change the destination directory
3421N/Afor <tt class="docutils literal"><span class="pre">make</span> <span class="pre">install</span></tt>. The equivalent for autoconfs <tt class="docutils literal"><span class="pre">/configure</span> <span class="pre">--prefix</span></tt>
3421N/Ain <a class="reference external" href="http://www.cmake.org">CMake</a> is:</p>
3421N/A<div class="highlight-c"><div class="highlight"><pre><span class="p">...</span>
3421N/A<span class="n">cmake</span> <span class="o">-</span><span class="n">DCMAKE_INSTALL_PREFIX</span><span class="o">:</span><span class="n">PATH</span><span class="o">=/</span><span class="n">some</span><span class="o">/</span><span class="n">other</span><span class="o">/</span><span class="n">path</span> <span class="p">..</span>
3421N/A<span class="n">make</span> <span class="n">install</span>
3421N/A</pre></div>
3421N/A</div>
3421N/A</div>
3421N/A</div>
3421N/A</div>
3421N/A<div class="section" id="android">
3421N/A<h3>Android<a class="headerlink" href="#android" title="Permalink to this headline">¶</a></h3>
3421N/A<p>Jansson can be built for Android platforms. Android.mk is in the
3421N/Asource root directory. The configuration header file is located in the
3421N/A<tt class="docutils literal"><span class="pre">android</span></tt> directory in the source distribution.</p>
3421N/A</div>
3421N/A<div class="section" id="other-systems">
3421N/A<h3>Other Systems<a class="headerlink" href="#other-systems" title="Permalink to this headline">¶</a></h3>
3421N/A<p>On non Unix-like systems, you may be unable to run the <tt class="docutils literal"><span class="pre">/configure</span></tt>
3421N/Ascript. In this case, follow these steps. All the files mentioned can
3421N/Abe found in the <tt class="docutils literal"><span class="pre">src/</span></tt> directory.</p>
3421N/A<ol class="arabic simple">
3421N/A<li>Create <tt class="docutils literal"><span class="pre">jansson_config.h</span></tt> (which has some platform-specific
3421N/Aparameters that are normally filled in by the <tt class="docutils literal"><span class="pre">/configure</span></tt>
3421N/Ascript). Edit <tt class="docutils literal"><span class="pre">jansson_config.h.in</span></tt>, replacing all <tt class="docutils literal"><span class="pre">&#64;variable&#64;</span></tt>
3421N/Aplaceholders, and rename the file to <tt class="docutils literal"><span class="pre">jansson_config.h</span></tt>.</li>
3421N/A<li>Make <tt class="docutils literal"><span class="pre">jansson.h</span></tt> and <tt class="docutils literal"><span class="pre">jansson_config.h</span></tt> available to the
3421N/Acompiler, so that they can be found when compiling programs that
3421N/Ause Jansson.</li>
3421N/A<li>Compile all the <tt class="docutils literal"><span class="pre">.c</span></tt> files (in the <tt class="docutils literal"><span class="pre">src/</span></tt> directory) into a
3421N/Alibrary file. Make the library available to the compiler, as in
3421N/Astep 2.</li>
3421N/A</ol>
3421N/A</div>
3421N/A<div class="section" id="building-the-documentation">
3421N/A<h3>Building the Documentation<a class="headerlink" href="#building-the-documentation" title="Permalink to this headline">¶</a></h3>
3421N/A<p>(This subsection describes how to build the HTML documentation you are
3421N/Acurrently reading, so it can be safely skipped.)</p>
3421N/A<p>Documentation is in the <tt class="docutils literal"><span class="pre">doc/</span></tt> subdirectory. It&#8217;s written in
3421N/A<a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> with <a class="reference external" href="http://sphinx.pocoo.org/">Sphinx</a> annotations. To generate the HTML
3421N/Adocumentation, invoke:</p>
3421N/A<div class="highlight-c"><div class="highlight"><pre><span class="n">make</span> <span class="n">html</span>
3421N/A</pre></div>
3421N/A</div>
3421N/A<p>and point your browser to <tt class="docutils literal"><span class="pre">doc/_build/html/index.html</span></tt>. <a class="reference external" href="http://sphinx.pocoo.org/">Sphinx</a> 1.0
3421N/Aor newer is required to generate the documentation.</p>
3421N/A</div>
3421N/A</div>
3421N/A<div class="section" id="compiling-programs-that-use-jansson">
3421N/A<h2>Compiling Programs that Use Jansson<a class="headerlink" href="#compiling-programs-that-use-jansson" title="Permalink to this headline">¶</a></h2>
3421N/A<p>Jansson involves one C header file, <tt class="file docutils literal"><span class="pre">jansson.h</span></tt>, so it&#8217;s enough
3421N/Ato put the line</p>
3421N/A<div class="highlight-c"><div class="highlight"><pre><span class="cp">#include &lt;jansson.h&gt;</span>
3421N/A</pre></div>
3421N/A</div>
3421N/A<p>in the beginning of every source file that uses Jansson.</p>
3421N/A<p>There&#8217;s also just one library to link with, <tt class="docutils literal"><span class="pre">libjansson</span></tt>. Compile and
3421N/Alink the program as follows:</p>
3421N/A<div class="highlight-c"><div class="highlight"><pre><span class="n">cc</span> <span class="o">-</span><span class="n">I /usr/include/jansson</span> <span class="o">-</span><span class="n">o</span> <span class="n">prog</span> <span class="n">prog</span><span class="p">.</span><span class="n">c</span> <span class="o">-</span><span class="n">ljansson</span>
3421N/A</pre></div>
3421N/A</div>
3421N/A<p>Starting from version 1.2, there&#8217;s also support for <a class="reference external" href="http://pkg-config.freedesktop.org/">pkg-config</a>:</p>
3421N/A<div class="highlight-c"><div class="highlight"><pre>cc -o prog prog.c `pkg-config --cflags --libs jansson`
3421N/A</pre></div>
3421N/A</div>
3421N/A</div>
3421N/A</div>
3421N/A
3421N/A
3421N/A </div>
3421N/A </div>
3421N/A </div>
3421N/A <div class="sphinxsidebar">
3421N/A <div class="sphinxsidebarwrapper">
3421N/A <h3><a href="index.html">Table Of Contents</a></h3>
3421N/A <ul>
3421N/A<li><a class="reference internal" href="#">Getting Started</a><ul>
3421N/A<li><a class="reference internal" href="#compiling-and-installing-jansson">Compiling and Installing Jansson</a><ul>
3421N/A<li><a class="reference internal" href="#unix-like-systems-including-mingw">Unix-like systems (including MinGW)</a></li>
3421N/A<li><a class="reference internal" href="#cmake-various-platforms-including-windows">CMake (various platforms, including Windows)</a><ul>
3421N/A<li><a class="reference internal" href="#unix-make-files">Unix (Make files)</a></li>
3421N/A<li><a class="reference internal" href="#windows-visual-studio">Windows (Visual Studio)</a></li>
3421N/A<li><a class="reference internal" href="#mac-osx-xcode">Mac OSX (Xcode)</a></li>
3421N/A<li><a class="reference internal" href="#additional-cmake-settings">Additional CMake settings</a><ul>
3421N/A<li><a class="reference internal" href="#shared-library">Shared library</a></li>
3421N/A<li><a class="reference internal" href="#changing-install-directory-same-as-autoconf-prefix">Changing install directory (same as autoconf &#8211;prefix)</a></li>
3421N/A</ul>
3421N/A</li>
3421N/A</ul>
3421N/A</li>
3421N/A<li><a class="reference internal" href="#android">Android</a></li>
3421N/A<li><a class="reference internal" href="#other-systems">Other Systems</a></li>
3421N/A<li><a class="reference internal" href="#building-the-documentation">Building the Documentation</a></li>
3421N/A</ul>
3421N/A</li>
3421N/A<li><a class="reference internal" href="#compiling-programs-that-use-jansson">Compiling Programs that Use Jansson</a></li>
3421N/A</ul>
3421N/A</li>
3421N/A</ul>
3421N/A
3421N/A <h4>Previous topic</h4>
3421N/A <p class="topless"><a href="index.html"
3421N/A title="previous chapter">Jansson Documentation</a></p>
3421N/A <h4>Next topic</h4>
3421N/A <p class="topless"><a href="upgrading.html"
3421N/A title="next chapter">Upgrading from 1.x</a></p>
3421N/A <h3>This Page</h3>
3421N/A <ul class="this-page-menu">
3421N/A <li><a href="_sources/gettingstarted.txt"
3421N/A rel="nofollow">Show Source</a></li>
3421N/A </ul>
3421N/A<div id="searchbox" style="display: none">
3421N/A <h3>Quick search</h3>
3421N/A <form class="search" action="search.html" method="get">
3421N/A <input type="text" name="q" />
3421N/A <input type="submit" value="Go" />
3421N/A <input type="hidden" name="check_keywords" value="yes" />
3421N/A <input type="hidden" name="area" value="default" />
3421N/A </form>
3421N/A <p class="searchtip" style="font-size: 90%">
3421N/A Enter search terms or a module, class or function name.
3421N/A </p>
3421N/A</div>
3421N/A<script type="text/javascript">$('#searchbox').show(0);</script>
3421N/A </div>
3421N/A </div>
3421N/A <div class="clearer"></div>
3421N/A </div>
3421N/A <div class="related">
3421N/A <h3>Navigation</h3>
3421N/A <ul>
3421N/A <li class="right" style="margin-right: 10px">
3421N/A <a href="genindex.html" title="General Index"
3421N/A >index</a></li>
3421N/A <li class="right" >
3421N/A <a href="upgrading.html" title="Upgrading from 1.x"
3421N/A >next</a> |</li>
3421N/A <li class="right" >
3421N/A <a href="index.html" title="Jansson Documentation"
3421N/A >previous</a> |</li>
3421N/A <li><a href="index.html">Jansson 2.7 documentation</a> &raquo;</li>
3421N/A </ul>
3421N/A </div>
3421N/A <div class="footer">
3421N/A &copy; Copyright 2009-2014, Petri Lehtinen.
3421N/A Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
3421N/A </div>
3421N/A </body>
3421N/A</html>