Hi!
I'm new to Qt and I am trying to use the
QJson Library.
I haven't compiled it, I've just imported QJson files in the QT Creator's project with "Add existing file" and added the
Code:
#include "json_driver.hh"
in my .h file.
Everything seems to be ok, but when I try to compile I get these errors:
Code:
Running build steps for project project...
Creating gdb macros library...
Configuration unchanged, skipping QMake step.
Starting: C:/Qt/2009.01/mingw/bin/mingw32-make.exe debug -w
mingw32-make: Entering directory `C:/Documents and Settings/username/My Documents/project'
C:/Qt/2009.01/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Documents and Settings/username/My Documents/project'
Makefile.Debug:209: warning: overriding commands for target `debug/json_driver.o'
Makefile.Debug:172: warning: ignoring old commands for target `debug/json_driver.o'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\Qt\2009.01\qt\include\QtCore" -I"c:\Qt\2009.01\qt\include\QtGui" -I"c:\Qt\2009.01\qt\include" -I"c:\Qt\2009.01\qt\include\ActiveQt" -I"debug" -I"." -I"c:\Qt\2009.01\qt\mkspecs\win32-g++" -o debug\widget.o widget.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\decifratore.exe debug/main.o debug/widget.o debug/json_driver.o debug/jsonconverterthread.o debug/json_scanner.o debug/json_parser.o debug/json_driver.o debug/moc_widget.o debug/moc_jsonconverterthread.o -L"c:\Qt\2009.01\qt\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directory `C:/Documents and Settings/username/My Documents/project'
mingw32-make: Leaving directory `C:/Documents and Settings/username/My Documents/project'
debug/json_driver.o: In function `ZN10JSonDriverC2Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:27: multiple definition of `JSonDriver::JSonDriver()'
debug/json_driver.o:C:/Documents and Settings/username/My Documents/project/json_driver.cc:27: first defined here
debug/json_driver.o: In function `ZN10JSonDriverC1Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:27: multiple definition of `JSonDriver::JSonDriver()'
debug/json_driver.o:C:/Documents and Settings/username/My Documents/project/json_driver.cc:27: first defined here
debug/json_driver.o: In function `ZN10JSonDriverD2Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:35: multiple definition of `JSonDriver::~JSonDriver()'
debug/json_driver.o:C:/Documents and Settings/username/My Documents/project/json_driver.cc:35: first defined here
debug/json_driver.o: In function `ZN10JSonDriverD1Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:35: multiple definition of `JSonDriver::~JSonDriver()'
debug/json_driver.o:C:/Documents and Settings/username/My Documents/project/json_driver.cc:35: first defined here
debug/json_driver.o: In function `ZN10JSonDriverD0Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:35: multiple definition of `JSonDriver::~JSonDriver()'
debug/json_driver.o:C:/Documents and Settings/username/My Documents/project/json_driver.cc:35: first defined here
debug/json_driver.o: In function `ZN10JSonDriver8setErrorE7QStringi':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:40: multiple definition of `JSonDriver::setError(QString, int)'
debug/json_driver.o:C:/Documents and Settings/username/My Documents/project/json_driver.cc:40: first defined here
debug/json_driver.o: In function `ZN10JSonDriver5parseEP9QIODevicePb':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:47: multiple definition of `JSonDriver::parse(QIODevice*, bool*)'
debug/json_driver.o:C:/Documents and Settings/username/My Documents/project/json_driver.cc:47: first defined here
debug/json_driver.o: In function `ZN10JSonDriver5parseERK7QStringPb':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:83: multiple definition of `JSonDriver::parse(QString const&, bool*)'
debug/json_driver.o:C:/Documents and Settings/username/My Documents/project/json_driver.cc:83: first defined here
debug/json_driver.o: In function `ZN10JSonDriverC2Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:27: undefined reference to `_imp___ZTV10JSonDriver'
debug/json_driver.o: In function `ZN10JSonDriverC1Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:27: undefined reference to `_imp___ZTV10JSonDriver'
debug/json_driver.o: In function `ZN10JSonDriverD2Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:35: undefined reference to `_imp___ZTV10JSonDriver'
debug/json_driver.o: In function `ZN10JSonDriverD1Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:35: undefined reference to `_imp___ZTV10JSonDriver'
debug/json_driver.o: In function `ZN10JSonDriverD0Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:35: undefined reference to `_imp___ZTV10JSonDriver'
debug/jsonconverterthread.o: In function `ZN19JSonConverterThread3runEv':
C:/Documents and Settings/username/My Documents/project/jsonconverterthread.cpp:37: undefined reference to `_imp___ZN10JSonDriverC1Ev'
C:/Documents and Settings/username/My Documents/project/jsonconverterthread.cpp:38: undefined reference to `_imp___ZN10JSonDriver5parseERK7QStringPb'
debug/json_parser.o: In function `ZN2yy11json_parser5errorERKNS_8locationERKSs':
C:/Documents and Settings/username/My Documents/project/json_parser.yy:201: undefined reference to `_imp___ZN10JSonDriver8setErrorE7QStringi'
debug/json_driver.o: In function `ZN10JSonDriverC2Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:27: undefined reference to `_imp___ZTV10JSonDriver'
debug/json_driver.o: In function `ZN10JSonDriverC1Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:27: undefined reference to `_imp___ZTV10JSonDriver'
debug/json_driver.o: In function `ZN10JSonDriverD2Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:35: undefined reference to `_imp___ZTV10JSonDriver'
debug/json_driver.o: In function `ZN10JSonDriverD1Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:35: undefined reference to `_imp___ZTV10JSonDriver'
debug/json_driver.o: In function `ZN10JSonDriverD0Ev':
C:/Documents and Settings/username/My Documents/project/json_driver.cc:35: undefined reference to `_imp___ZTV10JSonDriver'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\decifratore.exe] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project project
When executing build step 'Make'
widget.h and widget.cpp are mine.
Here's their code:
widget.h
Code:
#ifndef WIDGET_H
#define WIDGET_H
#include <QtGui>
#include <QVBoxLayout>
#include <QVariant>
#include "json_driver.hh"
namespace Ui
{
class WidgetClass;
}
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = 0);
~Widget();
private:
QLineEdit *test;
...
private slots:
void f();
...
};
#endif // WIDGET_H
widget.cpp
Code:
#include "widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
test=new QLineEdit("\"Tmax\":\"24\",");
...
}
Widget::~Widget()
{
}
void Widget::f()
{
QString str = test->text();
JSonDriver driver;
bool status;
QVariantMap result = driver.parse(str, &status).toMap();
if (status) {
qFatal("An error occured during parsing");
exit (1);
}
QMessageBox::about(this, tr("Test"), result["encoding"].toString());
}
Could you help me?
Thanks in advance