Yosef Meller edited this page May 7, 2018 · 5 revisions

Building and testing with Meson/Ninja

Thanks to David Seifert (@SoapGentoo), we (the maintainers) now use meson and ninja to build for debugging, as well as for continuous integration (see ). Other systems may work, but minor things like version strings might break.

First, install both meson (which requires Python3) and ninja.


cd jsoncpp/
#plain, debug, debugoptimized, release, minsize
meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . build-${LIB_TYPE}
ninja -v -C build-${LIB_TYPE} test

Building and testing with CMake

(Deprecated, but still works for now. The version string may soon be wrong.)

CMake is a C++ Makefiles/Solution generator. It is usually available on most Linux system as package. On Ubuntu:

sudo apt-get install cmake

Note that Python is also required to run the JSON reader/writer tests. If missing, the build will skip running those tests.

When running CMake, a few parameters are required:

  • A build directory where the makefiles/solution are generated. It is also used to store objects, libraries and executables files.
  • The generator to use: makefiles or Visual Studio solution? What version or Visual Studio, 32 or 64 bits solution?

Steps for generating solution/makefiles using cmake-gui:

  • Make "source code" point to the source directory.
  • Make "where to build the binary" point to the directory to use for the build.
  • Click on the "Grouped" check box.
  • Review JsonCpp build options (tick BUILD_SHARED_LIBS to build as a dynamic library).
  • Click the configure button at the bottom, then the generate button.
  • The generated solution/makefiles can be found in the binary directory.

Alternatively, from the command-line on Unix in the source directory:

mkdir -p build/debug
cd build/debug

For a good pkg-config file, add:


Running cmake -h will display the list of available generators (passed using the -G option).

By default CMake hides compilation commands. This can be modified by specifying -DCMAKE_VERBOSE_MAKEFILE=true when generating makefiles.

When building the solution file on Visual Studio, it would try to run the tests. In this case, or when running the tests from the command line, if you build a DLL of jsoncpp, then it must be installed, or at least copied into the output directory holding jsontestrunner_exe.exe

Building and testing with Conan

(This works, but it currently uses cmake, which is deprecated.)

Conan is an open source package manager intended for C/C++ projects. It is cross platform and build system agnostic.

Conan requires Python for running, and can be installed using pip:

pip install conan

Detailed instructions can be found on conan docs.

For build jsoncpp with conan, you need to create a conanfile.txt or a The first is simpler, but the second is more flexible.

This is a sample conanfile.txt:



Note: cmake is not required, you can use other integrations. Or you can set the appropriate environment variables, using virtualenv generators.

Then run the following command from the conanfile directory:

conan install --build missing

This will try to download the appropriate package for your settings (OS, compiler, architecture) from the recipe packages. If it is not found, the package will be built.

Note: you do not need to install cmake to build jsoncpp using conan, because the recipe will download it automatically.

If you need, you can customize the jsoncpp recipe. Just clone/fork it from github.

See integrations instructions for how to use your build system with conan.

Building and testing with scons

No longer supported. But you might be able to recover it at commit at .

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.