2

I try to use jsoncpp library with c++ on Ubuntu. I compiled the code and built the library with scons. Now I can compile a simple programme:

#include "json/json.h"
#include <json/value.h>
#include <json/writer.h>
int main()
{
    return 0;
}

I use this command to compile:

g++ test.cpp -usr/lib/libjson_linux-gcc-4.8_libmt

I conclude that the compiler knows where to find the library. The problem comes when I declare a json object:

Json::Value root;

Then I have this error message: undefined reference to « Json::Value::Value(Json::ValueType) »

How can I fix this problem?

4
  • -L to point to library location, -l to link to a library Commented Apr 8, 2015 at 15:41
  • 1
    So -L/usr/lib -ljsoncpp Commented Apr 8, 2015 at 15:45
  • You say you build library with scons. Did you build jsoncpp library yourself. Maybe compiled does not know where to search your custom library Commented Apr 8, 2015 at 16:09
  • I did build the library myself and then I copied the file libjson_linux-gcc-4.8_libmt in /usr/lib. I tried with -L/usr/lib -ljsoncpp And it works ! Thanks Commented Apr 9, 2015 at 16:32

1 Answer 1

1

For CodeBlocks (Ubuntu 14.04)

I have faced same problem in my codeblocks IDE after installing jsconcpp. This is how I rectified my problem.

Got to project>Build Options>linker settings and in the link libraries add jsconcpp and click ok

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.