Compiling and Installing Jansson¶
The Jansson source is available at http://www.digip.org/jansson/releases/.
Unix-like systems (including MinGW)¶
Unpack the source tarball and change to the source directory:
bunzip2 -c jansson-2.8.tar.bz2 | tar xf - cd jansson-2.8
./configure make make check make install
To change the destination directory (
/usr/local by default), use
--prefix=DIR argument to
--help for the list of all possible configuration options.
make check runs the test suite distributed with
Jansson. This step is not strictly necessary, but it may find possible
problems that Jansson has on your platform. If any problems are found,
please report them.
If you obtained the source from a Git repository (or any other source
control system), there’s no
./configure script as it’s not kept in
version control. To create the script, the build system needs to be
bootstrapped. There are many ways to do this, but the easiest one is
This command creates the
./configure script, which can then be
used as described above.
CMake (various platforms, including Windows)¶
Jansson can be built using CMake. Create a build directory for an
out-of-tree build, change to that directory, and run
cmake-gui, or similar) to configure the project.
See the examples below for more detailed information.
In the below examples
.. is used as an argument for
This is simply the path to the jansson project root directory.
In the example it is assumed you’ve created a sub-directory
and are using that. You could use any path you want.
Unix (Make files)¶
Generating make files on unix:
bunzip2 -c jansson-2.8.tar.bz2 | tar xf - cd jansson-2.8 mkdir build cd build cmake .. # or ccmake .. for a GUI.
Then to build:
make make check make install
Windows (Visual Studio)¶
Creating Visual Studio project files from the command line:
<unpack> cd jansson-2.8 md build cd build cmake -G "Visual Studio 10" ..
You will now have a Visual Studio Solution in your build directory.
To run the unit tests build the
If you prefer a GUI the
cmake line in the above example can
be replaced with:
For command line help (including a list of available generators) for CMake simply run:
To list available CMake settings (and what they are currently set to) for the project, run:
cmake -LH ..
Mac OSX (Xcode)¶
If you prefer using Xcode instead of make files on OSX, do the following. (Use the same steps as for Unix):
... cmake -G "Xcode" ..
Additional CMake settings¶
Jansson can be built for Android platforms. Android.mk is in the
source root directory. The configuration header file is located in the
android directory in the source distribution.
On non Unix-like systems, you may be unable to run the
script. In this case, follow these steps. All the files mentioned can
be found in the
jansson_config.h(which has some platform-specific parameters that are normally filled in by the
jansson_config.h.in, replacing all
@variable@placeholders, and rename the file to
jansson_config.havailable to the compiler, so that they can be found when compiling programs that use Jansson.
- Compile all the
.cfiles (in the
src/directory) into a library file. Make the library available to the compiler, as in step 2.
Building the Documentation¶
(This subsection describes how to build the HTML documentation you are currently reading, so it can be safely skipped.)
and point your browser to
doc/_build/html/index.html. Sphinx 1.0
or newer is required to generate the documentation.
Compiling Programs that Use Jansson¶
Jansson involves one C header file,
jansson.h, so it’s enough
to put the line
in the beginning of every source file that uses Jansson.
There’s also just one library to link with,
libjansson. Compile and
link the program as follows:
cc -o prog prog.c -ljansson
Starting from version 1.2, there’s also support for pkg-config:
cc -o prog prog.c `pkg-config --cflags --libs jansson`