Search code examples
c++linkerg++jsoncpp

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

Solution

  • 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.