TranslateProject/sources/tech/20140807 Linux FAQs with Answers--How to fix 'fatal error--jsoncpp or json or json.h--No such file or directory'.md
2014-08-07 18:41:21 +08:00

1.6 KiB

Linux FAQs with Answers--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 

via: http://ask.xmodulo.com/fix-fatal-error-jsoncpp.html

译者:译者ID 校对:校对者ID

本文由 LCTT 原创翻译,Linux中国 荣誉推出