Question

I've successfully(?) installed the QJson library following the instructions in the archive. But the compiler gives me this error:

Undefined reference to QJSon::Parser::Parser().

I've found where library files have been installed: it's /usr/local/include/json directory. But there are only *.h files in it.

The minimal code:

main.cpp

#include <QtGui/QApplication>
#include <qjson/parser.h>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QJson::Parser parser;
    return a.exec();
}

I use linux.

Where are *.cpp files? What did I do wrong? Why isn't the library complete?

Was it helpful?

Solution

At first you have to find a library file rather than a *.cpp file. Maybe it has a name like "libqjson.a" or "libqjson.so" and compile this library with your code or pass this keys to

g++ -L(lib path) -lqjson

As it turned out (see comments below), your library path is /usr/local/lib, so this line becomes:

g++ -L/usr/local/lib -lqjson

Using Qt (qmake), just add this line to your .pro file in order to pass these two flags to g++:

LIBS += -L/usr/local/lib -lqjson
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top