Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link jsoncpp?

How can I link jsoncpp with a C++ program using g++? I tried:

g++ -o program program.cpp -L/path/to/library/files -ljsoncpp, -ljson, -llibjsoncpp

but g++ keeps saying:

/usr/bin/ld: cannot find -lsomething
like image 592
Donny Avatar asked Feb 09 '11 20:02

Donny


2 Answers

You could also try using the new Amalgamated version of jsoncpp, which is new as of version 0.6.0.

The Amalgamated version allows you to use jsoncpp by adding just one directory with a couple of header files and one .cpp file to your project. You then can directly compile jsoncpp into your program with no worries about having to link to any jsoncpp libraries.

like image 136
Gordon Brandly Avatar answered Sep 28 '22 05:09

Gordon Brandly


Look in /path/to/library/files to see what your *.a file is really named. On my system, I link with:

-ljson_linux-gcc-4.4.3_libmt

Some libraries will create a link from lib<name>.a to lib<name>-<version>.a for you, but I don't think that jsoncpp does this automatically. Therefore, you need to specify the complete name when linking.

like image 37
JaredC Avatar answered Sep 28 '22 05:09

JaredC