How to fix "fatal error: jsoncpp/json/json.h: No such file or directory"

Last updated on June 20, 2020 by Dan Nanni

Question: I am trying compile a C++ application, but I am getting the following error:
fatal error: jsoncpp/json/json.h: No such file or directory
How can I fix this problem?

The error indicates that you are missing JsonCpp development files (i.e., JsonCpp library and header files). JsonCpp is a C++ library for JSON-formatted data manipulation. Here is how to install JsonCpp development files on various Linux distros.

Install JsonCpp on Ubuntu, Debian or Linux Mint

$ sudo apt-get install libjsoncpp-dev

Install JsonCpp on Fedora or CentOS/RHEL 7 or Higher

$ sudo yum install jsoncpp-devel

On CentOS/RHEL 6 or lower, JsonCpp is not available as a pre-built package. So you can build and install JsonCpp from the source.

Install JsonCpp from the Source on Fedora, CentOS or RHEL

$ sudo yum install cmake
$ git clone https://github.com/open-source-parsers/jsoncpp.git
$ cd jsoncpp
$ mkdir -p build/debug
$ cd build/debug
$ cmake -DCMAKE_BUILD_TYPE=debug -DJSONCPP_LIB_BUILD_SHARED=OFF -G "Unix Makefiles" ../../
$ make
$ sudo make install

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal (Credit Card) or Bitcoin (1M161JGAkz3oaHNvTiPFjNYkeABox8rb4g).

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean