5

As the question tells how should I install jsonccpp in ubuntu 14.04. I have downloaded the jsoncpp-src-0.5.0.tar.gz form sourceforge. Then I opened nautilus using sudo and copied,pasted and extracted the tar.gz file in /opt. I have installed the cmake and used this code to install as suggested in the jsoncpp github

cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF \
      -DARCHIVE_INSTALL_DIR=. -G "Unix Makefiles"

But its giving this error

CMake Error: The source directory "/opt/jsoncpp-src-0.5.0" does not
appear to contain CMakeLists.txt. Specify --help for usage, or press
the help button on the CMake GUI.
  • Codeblocks is used as C++ development IDE
Eka
  • 2,917
  • 12
  • 38
  • 58

1 Answers1

7

Your installation with cmake fails because you are downloading a very old version of jsoncpp from SourceForge , a version that actually does not use cmake. The file README.txt with the 0.5.0 tarball has the details:

* Building/Testing:
 =================

JsonCpp uses Scons (http://www.scons.org) as a build system. Scons
requires python to be installed (http://www.python.org).

Newer versions of jsoncpp are seen on GitHub (latest stable version is 1.7.3) and these actually do use cmake to build.

However a reasonable version exists in the Trusty Repositories and the following command will get you jsoncpp 0.6.0:

sudo apt-get install libjsoncpp-dev libjsoncpp0

Here are the details of the package on my system:

andrew@corinth:~$ apt-cache policy libjsoncpp-dev
libjsoncpp-dev:
  Installed: 0.6.0~rc2-3ubuntu1
  Candidate: 0.6.0~rc2-3ubuntu1
  Version table:
 *** 0.6.0~rc2-3ubuntu1 0
        500 http://au.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status
andrew@corinth:~$ 

If you need a newer version this can be built from source but perhaps this version is enough for your purposes...

andrew.46
  • 37,085
  • 25
  • 149
  • 228
  • I have installed using sudo and I am using codeblocks as the IDE but its not recognizing the header `#include ` json/json.h: No such file or directory – Eka Jul 23 '16 at 05:00
  • 1
    @Eka Try the command `sudo find /usr -name json.h` Running this on my Trusty system shows `/usr/include/jsoncpp/json/json.h` – andrew.46 Jul 23 '16 at 05:03
  • Hey thanks for the info . It was in the same location but error was in the naming header. I used `#include ` and now its working – Eka Jul 23 '16 at 05:08
  • 1
    @Eka Great news! And you have a good day as well :) – andrew.46 Jul 23 '16 at 05:12