5

How do I resolve the following linker error w.r.t jsoncpp operator=.

I create a Json::Value object like this

Json::Value pt;
pt["type"] = 5;
pt["uuid"] = "f8c74622-d45e-4cfa-fe00-5e7042431c72";
pt["start frame"] = 10;
pt["duration"] = 20;
pt["payload"] = "aedddefffsadf";

This gives the following linker error when I try to link against the default libjsoncpp-dev shipped with Ubuntu 14.04

undefined reference to `Json::Value::operator=(Json::Value)'

extra info:

And I don't get this linker error when compiled and linked against the latest jsoncpp from GitHub.

value.h (installed by ubuntu apt) in /usr/include/jsoncpp/json has

Value &operator=( const Value &other );

and the latest jsoncpp value.h has

Value &operator=(Value other);
satheeshram
  • 161
  • 1
  • 9
  • You'd better add tags `c++` and `c++-11` – Severin Pappadeux Feb 11 '15 at 03:05
  • 1
    Generally you need to compile with the same version of the header files as the version of the library you (eventually) want to link with. If you compile with one version of the headers and link with a different version of the library, bad things tend to happen. If you want to be able to link with default libjsoncpp-dev from Ubuntu 14.04, be sure to use those header files. – Chris Dodd Feb 12 '15 at 00:51

1 Answers1

2

Debian ships with jsoncpp-0.6.0-rc2. I'll bet Ubuntu does too.

Simply switch to jsoncpp-0.8.z, which are binary-compatible with 0.6.0-rc2 and include most enhancements and bug-fixes from 1.y.z.

Actually Debian is switching to 0.8.z presently. Until Ubuntu updates their shipped version, you might have to avoid new features (mainly the Builders) and instead use the deprecated Readers/Writers, which is probably what you do already. So it should be easy for you to get everything working.

cdunn2001
  • 17,657
  • 8
  • 55
  • 45