4141
|
1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
2 |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
3 |
|
|
4 |
|
|
5 |
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
6 |
<head>
|
|
7 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
8 |
|
|
9 |
<title>Getting Started — Jansson 2.7 documentation</title>
|
|
10 |
|
|
11 |
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
|
12 |
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
13 |
|
|
14 |
<script type="text/javascript">
|
|
15 |
var DOCUMENTATION_OPTIONS = {
|
|
16 |
URL_ROOT: './',
|
|
17 |
VERSION: '2.7',
|
|
18 |
COLLAPSE_INDEX: false,
|
|
19 |
FILE_SUFFIX: '.html',
|
|
20 |
HAS_SOURCE: true
|
|
21 |
};
|
|
22 |
</script>
|
|
23 |
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
24 |
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
25 |
<script type="text/javascript" src="_static/doctools.js"></script>
|
|
26 |
<link rel="top" title="Jansson 2.7 documentation" href="index.html" />
|
|
27 |
<link rel="next" title="Upgrading from 1.x" href="upgrading.html" />
|
|
28 |
<link rel="prev" title="Jansson Documentation" href="index.html" />
|
|
29 |
</head>
|
|
30 |
<body>
|
|
31 |
<div class="related">
|
|
32 |
<h3>Navigation</h3>
|
|
33 |
<ul>
|
|
34 |
<li class="right" style="margin-right: 10px">
|
|
35 |
<a href="genindex.html" title="General Index"
|
|
36 |
accesskey="I">index</a></li>
|
|
37 |
<li class="right" >
|
|
38 |
<a href="upgrading.html" title="Upgrading from 1.x"
|
|
39 |
accesskey="N">next</a> |</li>
|
|
40 |
<li class="right" >
|
|
41 |
<a href="index.html" title="Jansson Documentation"
|
|
42 |
accesskey="P">previous</a> |</li>
|
|
43 |
<li><a href="index.html">Jansson 2.7 documentation</a> »</li>
|
|
44 |
</ul>
|
|
45 |
</div>
|
|
46 |
|
|
47 |
<div class="document">
|
|
48 |
<div class="documentwrapper">
|
|
49 |
<div class="bodywrapper">
|
|
50 |
<div class="body">
|
|
51 |
|
|
52 |
<div class="section" id="getting-started">
|
|
53 |
<h1>Getting Started<a class="headerlink" href="#getting-started" title="Permalink to this headline">¶</a></h1>
|
|
54 |
<div class="section" id="compiling-and-installing-jansson">
|
|
55 |
<h2>Compiling and Installing Jansson<a class="headerlink" href="#compiling-and-installing-jansson" title="Permalink to this headline">¶</a></h2>
|
|
56 |
<p>The Jansson source is available at
|
|
57 |
<a class="reference external" href="http://www.digip.org/jansson/releases/">http://www.digip.org/jansson/releases/</a>.</p>
|
|
58 |
<div class="section" id="unix-like-systems-including-mingw">
|
|
59 |
<h3>Unix-like systems (including MinGW)<a class="headerlink" href="#unix-like-systems-including-mingw" title="Permalink to this headline">¶</a></h3>
|
|
60 |
<p>Unpack the source tarball and change to the source directory:</p>
|
|
61 |
<pre class="literal-block">
|
|
62 |
bunzip2 -c jansson-2.7.tar.bz2 | tar xf -
|
|
63 |
cd jansson-2.7
|
|
64 |
</pre>
|
|
65 |
<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
|
|
66 |
compiling and installing is extremely simple:</p>
|
|
67 |
<div class="highlight-c"><div class="highlight"><pre><span class="p">.</span><span class="o">/</span><span class="n">configure</span>
|
|
68 |
<span class="n">make</span>
|
|
69 |
<span class="n">make</span> <span class="n">check</span>
|
|
70 |
<span class="n">make</span> <span class="n">install</span>
|
|
71 |
</pre></div>
|
|
72 |
</div>
|
|
73 |
<p>To change the destination directory (<tt class="docutils literal"><span class="pre">/usr/local</span></tt> by default), use
|
|
74 |
the <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>
|
|
75 |
<span class="pre">--help</span></tt> for the list of all possible installation options. (There are
|
|
76 |
no options to customize the resulting Jansson binary.)</p>
|
|
77 |
<p>The command <tt class="docutils literal"><span class="pre">make</span> <span class="pre">check</span></tt> runs the test suite distributed with
|
|
78 |
Jansson. This step is not strictly necessary, but it may find possible
|
|
79 |
problems that Jansson has on your platform. If any problems are found,
|
|
80 |
please report them.</p>
|
|
81 |
<p>If you obtained the source from a Git repository (or any other source
|
|
82 |
control system), there’s no <tt class="docutils literal"><span class="pre">./configure</span></tt> script as it’s not kept in
|
|
83 |
version control. To create the script, the build system needs to be
|
|
84 |
bootstrapped. There are many ways to do this, but the easiest one is
|
|
85 |
to use <tt class="docutils literal"><span class="pre">autoreconf</span></tt>:</p>
|
|
86 |
<div class="highlight-c"><div class="highlight"><pre><span class="n">autoreconf</span> <span class="o">-</span><span class="n">vi</span>
|
|
87 |
</pre></div>
|
|
88 |
</div>
|
|
89 |
<p>This command creates the <tt class="docutils literal"><span class="pre">./configure</span></tt> script, which can then be
|
|
90 |
used as described above.</p>
|
|
91 |
</div>
|
|
92 |
<div class="section" id="cmake-various-platforms-including-windows">
|
|
93 |
<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>
|
|
94 |
<p>Jansson can be built using <a class="reference external" href="http://www.cmake.org">CMake</a>. Create a build directory for an
|
|
95 |
out-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>,
|
|
96 |
<tt class="docutils literal"><span class="pre">cmake-gui</span></tt>, or similar) to configure the project.</p>
|
|
97 |
<p>See the examples below for more detailed information.</p>
|
|
98 |
<div class="admonition note">
|
|
99 |
<p class="first admonition-title">Note</p>
|
|
100 |
<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>.
|
|
101 |
This is simply the path to the jansson project root directory.
|
|
102 |
In the example it is assumed you’ve created a sub-directory <tt class="docutils literal"><span class="pre">build</span></tt>
|
|
103 |
and are using that. You could use any path you want.</p>
|
|
104 |
</div>
|
|
105 |
<div class="section" id="unix-make-files">
|
|
106 |
<span id="build-cmake-unix"></span><h4>Unix (Make files)<a class="headerlink" href="#unix-make-files" title="Permalink to this headline">¶</a></h4>
|
|
107 |
<p>Generating make files on unix:</p>
|
|
108 |
<pre class="literal-block">
|
|
109 |
bunzip2 -c jansson-2.7.tar.bz2 | tar xf -
|
|
110 |
cd jansson-2.7
|
|
111 |
|
|
112 |
mkdir build
|
|
113 |
cd build
|
|
114 |
cmake .. # or <tt class="xref c c-func docutils literal"><span class="pre">ccmake</span> <span class="pre">..()</span></tt> for a GUI.
|
|
115 |
</pre>
|
|
116 |
<p>Then to build:</p>
|
|
117 |
<div class="highlight-c"><div class="highlight"><pre><span class="n">make</span>
|
|
118 |
<span class="n">make</span> <span class="n">check</span>
|
|
119 |
<span class="n">make</span> <span class="n">install</span>
|
|
120 |
</pre></div>
|
|
121 |
</div>
|
|
122 |
</div>
|
|
123 |
<div class="section" id="windows-visual-studio">
|
|
124 |
<h4>Windows (Visual Studio)<a class="headerlink" href="#windows-visual-studio" title="Permalink to this headline">¶</a></h4>
|
|
125 |
<p>Creating Visual Studio project files from the command line:</p>
|
|
126 |
<pre class="literal-block">
|
|
127 |
<unpack>
|
|
128 |
cd jansson-2.7
|
|
129 |
|
|
130 |
md build
|
|
131 |
cd build
|
|
132 |
cmake -G "Visual Studio 10" ..
|
|
133 |
</pre>
|
|
134 |
<p>You will now have a <em>Visual Studio Solution</em> in your build directory.
|
|
135 |
To run the unit tests build the <tt class="docutils literal"><span class="pre">RUN_TESTS</span></tt> project.</p>
|
|
136 |
<p>If you prefer a GUI the <tt class="docutils literal"><span class="pre">cmake</span></tt> line in the above example can
|
|
137 |
be replaced with:</p>
|
|
138 |
<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>
|
|
139 |
</pre></div>
|
|
140 |
</div>
|
|
141 |
<p>For command line help (including a list of available generators)
|
|
142 |
for <a class="reference external" href="http://www.cmake.org">CMake</a> simply run:</p>
|
|
143 |
<div class="highlight-c"><div class="highlight"><pre><span class="n">cmake</span>
|
|
144 |
</pre></div>
|
|
145 |
</div>
|
|
146 |
<p>To list available <a class="reference external" href="http://www.cmake.org">CMake</a> settings (and what they are currently set to)
|
|
147 |
for the project, run:</p>
|
|
148 |
<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>
|
|
149 |
</pre></div>
|
|
150 |
</div>
|
|
151 |
</div>
|
|
152 |
<div class="section" id="mac-osx-xcode">
|
|
153 |
<h4>Mac OSX (Xcode)<a class="headerlink" href="#mac-osx-xcode" title="Permalink to this headline">¶</a></h4>
|
|
154 |
<p>If you prefer using Xcode instead of make files on OSX,
|
|
155 |
do the following. (Use the same steps as
|
|
156 |
for <a class="reference internal" href="#build-cmake-unix"><em>Unix</em></a>):</p>
|
|
157 |
<div class="highlight-c"><div class="highlight"><pre><span class="p">...</span>
|
|
158 |
<span class="n">cmake</span> <span class="o">-</span><span class="n">G</span> <span class="s">"Xcode"</span> <span class="p">..</span>
|
|
159 |
</pre></div>
|
|
160 |
</div>
|
|
161 |
</div>
|
|
162 |
<div class="section" id="additional-cmake-settings">
|
|
163 |
<h4>Additional CMake settings<a class="headerlink" href="#additional-cmake-settings" title="Permalink to this headline">¶</a></h4>
|
|
164 |
<div class="section" id="shared-library">
|
|
165 |
<h5>Shared library<a class="headerlink" href="#shared-library" title="Permalink to this headline">¶</a></h5>
|
|
166 |
<p>By default the <a class="reference external" href="http://www.cmake.org">CMake</a> project will generate build files for building the
|
|
167 |
static library. To build the shared version use:</p>
|
|
168 |
<div class="highlight-c"><div class="highlight"><pre><span class="p">...</span>
|
|
169 |
<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>
|
|
170 |
</pre></div>
|
|
171 |
</div>
|
|
172 |
</div>
|
|
173 |
<div class="section" id="changing-install-directory-same-as-autoconf-prefix">
|
|
174 |
<h5>Changing install directory (same as autoconf –prefix)<a class="headerlink" href="#changing-install-directory-same-as-autoconf-prefix" title="Permalink to this headline">¶</a></h5>
|
|
175 |
<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
|
|
176 |
for <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>
|
|
177 |
in <a class="reference external" href="http://www.cmake.org">CMake</a> is:</p>
|
|
178 |
<div class="highlight-c"><div class="highlight"><pre><span class="p">...</span>
|
|
179 |
<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>
|
|
180 |
<span class="n">make</span> <span class="n">install</span>
|
|
181 |
</pre></div>
|
|
182 |
</div>
|
|
183 |
</div>
|
|
184 |
</div>
|
|
185 |
</div>
|
|
186 |
<div class="section" id="android">
|
|
187 |
<h3>Android<a class="headerlink" href="#android" title="Permalink to this headline">¶</a></h3>
|
|
188 |
<p>Jansson can be built for Android platforms. Android.mk is in the
|
|
189 |
source root directory. The configuration header file is located in the
|
|
190 |
<tt class="docutils literal"><span class="pre">android</span></tt> directory in the source distribution.</p>
|
|
191 |
</div>
|
|
192 |
<div class="section" id="other-systems">
|
|
193 |
<h3>Other Systems<a class="headerlink" href="#other-systems" title="Permalink to this headline">¶</a></h3>
|
|
194 |
<p>On non Unix-like systems, you may be unable to run the <tt class="docutils literal"><span class="pre">./configure</span></tt>
|
|
195 |
script. In this case, follow these steps. All the files mentioned can
|
|
196 |
be found in the <tt class="docutils literal"><span class="pre">src/</span></tt> directory.</p>
|
|
197 |
<ol class="arabic simple">
|
|
198 |
<li>Create <tt class="docutils literal"><span class="pre">jansson_config.h</span></tt> (which has some platform-specific
|
|
199 |
parameters that are normally filled in by the <tt class="docutils literal"><span class="pre">./configure</span></tt>
|
|
200 |
script). Edit <tt class="docutils literal"><span class="pre">jansson_config.h.in</span></tt>, replacing all <tt class="docutils literal"><span class="pre">@variable@</span></tt>
|
|
201 |
placeholders, and rename the file to <tt class="docutils literal"><span class="pre">jansson_config.h</span></tt>.</li>
|
|
202 |
<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
|
|
203 |
compiler, so that they can be found when compiling programs that
|
|
204 |
use Jansson.</li>
|
|
205 |
<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
|
|
206 |
library file. Make the library available to the compiler, as in
|
|
207 |
step 2.</li>
|
|
208 |
</ol>
|
|
209 |
</div>
|
|
210 |
<div class="section" id="building-the-documentation">
|
|
211 |
<h3>Building the Documentation<a class="headerlink" href="#building-the-documentation" title="Permalink to this headline">¶</a></h3>
|
|
212 |
<p>(This subsection describes how to build the HTML documentation you are
|
|
213 |
currently reading, so it can be safely skipped.)</p>
|
|
214 |
<p>Documentation is in the <tt class="docutils literal"><span class="pre">doc/</span></tt> subdirectory. It’s written in
|
|
215 |
<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
|
|
216 |
documentation, invoke:</p>
|
|
217 |
<div class="highlight-c"><div class="highlight"><pre><span class="n">make</span> <span class="n">html</span>
|
|
218 |
</pre></div>
|
|
219 |
</div>
|
|
220 |
<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
|
|
221 |
or newer is required to generate the documentation.</p>
|
|
222 |
</div>
|
|
223 |
</div>
|
|
224 |
<div class="section" id="compiling-programs-that-use-jansson">
|
|
225 |
<h2>Compiling Programs that Use Jansson<a class="headerlink" href="#compiling-programs-that-use-jansson" title="Permalink to this headline">¶</a></h2>
|
|
226 |
<p>Jansson involves one C header file, <tt class="file docutils literal"><span class="pre">jansson.h</span></tt>, so it’s enough
|
|
227 |
to put the line</p>
|
|
228 |
<div class="highlight-c"><div class="highlight"><pre><span class="cp">#include <jansson.h></span>
|
|
229 |
</pre></div>
|
|
230 |
</div>
|
|
231 |
<p>in the beginning of every source file that uses Jansson.</p>
|
|
232 |
<p>There’s also just one library to link with, <tt class="docutils literal"><span class="pre">libjansson</span></tt>. Compile and
|
|
233 |
link the program as follows:</p>
|
|
234 |
<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>
|
|
235 |
</pre></div>
|
|
236 |
</div>
|
|
237 |
<p>Starting from version 1.2, there’s also support for <a class="reference external" href="http://pkg-config.freedesktop.org/">pkg-config</a>:</p>
|
|
238 |
<div class="highlight-c"><div class="highlight"><pre>cc -o prog prog.c `pkg-config --cflags --libs jansson`
|
|
239 |
</pre></div>
|
|
240 |
</div>
|
|
241 |
</div>
|
|
242 |
</div>
|
|
243 |
|
|
244 |
|
|
245 |
</div>
|
|
246 |
</div>
|
|
247 |
</div>
|
|
248 |
<div class="sphinxsidebar">
|
|
249 |
<div class="sphinxsidebarwrapper">
|
|
250 |
<h3><a href="index.html">Table Of Contents</a></h3>
|
|
251 |
<ul>
|
|
252 |
<li><a class="reference internal" href="#">Getting Started</a><ul>
|
|
253 |
<li><a class="reference internal" href="#compiling-and-installing-jansson">Compiling and Installing Jansson</a><ul>
|
|
254 |
<li><a class="reference internal" href="#unix-like-systems-including-mingw">Unix-like systems (including MinGW)</a></li>
|
|
255 |
<li><a class="reference internal" href="#cmake-various-platforms-including-windows">CMake (various platforms, including Windows)</a><ul>
|
|
256 |
<li><a class="reference internal" href="#unix-make-files">Unix (Make files)</a></li>
|
|
257 |
<li><a class="reference internal" href="#windows-visual-studio">Windows (Visual Studio)</a></li>
|
|
258 |
<li><a class="reference internal" href="#mac-osx-xcode">Mac OSX (Xcode)</a></li>
|
|
259 |
<li><a class="reference internal" href="#additional-cmake-settings">Additional CMake settings</a><ul>
|
|
260 |
<li><a class="reference internal" href="#shared-library">Shared library</a></li>
|
|
261 |
<li><a class="reference internal" href="#changing-install-directory-same-as-autoconf-prefix">Changing install directory (same as autoconf –prefix)</a></li>
|
|
262 |
</ul>
|
|
263 |
</li>
|
|
264 |
</ul>
|
|
265 |
</li>
|
|
266 |
<li><a class="reference internal" href="#android">Android</a></li>
|
|
267 |
<li><a class="reference internal" href="#other-systems">Other Systems</a></li>
|
|
268 |
<li><a class="reference internal" href="#building-the-documentation">Building the Documentation</a></li>
|
|
269 |
</ul>
|
|
270 |
</li>
|
|
271 |
<li><a class="reference internal" href="#compiling-programs-that-use-jansson">Compiling Programs that Use Jansson</a></li>
|
|
272 |
</ul>
|
|
273 |
</li>
|
|
274 |
</ul>
|
|
275 |
|
|
276 |
<h4>Previous topic</h4>
|
|
277 |
<p class="topless"><a href="index.html"
|
|
278 |
title="previous chapter">Jansson Documentation</a></p>
|
|
279 |
<h4>Next topic</h4>
|
|
280 |
<p class="topless"><a href="upgrading.html"
|
|
281 |
title="next chapter">Upgrading from 1.x</a></p>
|
|
282 |
<h3>This Page</h3>
|
|
283 |
<ul class="this-page-menu">
|
|
284 |
<li><a href="_sources/gettingstarted.txt"
|
|
285 |
rel="nofollow">Show Source</a></li>
|
|
286 |
</ul>
|
|
287 |
<div id="searchbox" style="display: none">
|
|
288 |
<h3>Quick search</h3>
|
|
289 |
<form class="search" action="search.html" method="get">
|
|
290 |
<input type="text" name="q" />
|
|
291 |
<input type="submit" value="Go" />
|
|
292 |
<input type="hidden" name="check_keywords" value="yes" />
|
|
293 |
<input type="hidden" name="area" value="default" />
|
|
294 |
</form>
|
|
295 |
<p class="searchtip" style="font-size: 90%">
|
|
296 |
Enter search terms or a module, class or function name.
|
|
297 |
</p>
|
|
298 |
</div>
|
|
299 |
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
300 |
</div>
|
|
301 |
</div>
|
|
302 |
<div class="clearer"></div>
|
|
303 |
</div>
|
|
304 |
<div class="related">
|
|
305 |
<h3>Navigation</h3>
|
|
306 |
<ul>
|
|
307 |
<li class="right" style="margin-right: 10px">
|
|
308 |
<a href="genindex.html" title="General Index"
|
|
309 |
>index</a></li>
|
|
310 |
<li class="right" >
|
|
311 |
<a href="upgrading.html" title="Upgrading from 1.x"
|
|
312 |
>next</a> |</li>
|
|
313 |
<li class="right" >
|
|
314 |
<a href="index.html" title="Jansson Documentation"
|
|
315 |
>previous</a> |</li>
|
|
316 |
<li><a href="index.html">Jansson 2.7 documentation</a> »</li>
|
|
317 |
</ul>
|
|
318 |
</div>
|
|
319 |
<div class="footer">
|
|
320 |
© Copyright 2009-2014, Petri Lehtinen.
|
|
321 |
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
|
|
322 |
</div>
|
|
323 |
</body>
|
|
324 |
</html>
|