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

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.

On Debian, Ubuntu or Linux Mint:

$ sudo apt-get install libjsoncpp-dev

On Fedora:

$ sudo yum install jsoncpp-devel

On CentOS, JsonCpp is not available as a pre-built package. So you can build and install JsonCpp from the source as follows.

$ 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

Subscribe to Ask Xmodulo

Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.

Leave a comment

Your email address will not be published. Required fields are marked *