"Multiple definition of" and "undefined reference to" in QT Creator with QJson lib
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
"Multiple definition of" and "undefined reference to" in QT Creator with QJson lib
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:
Also, other than json_driver.o, is it necessary to link all of the other JSon object files with your code?
Lastly, and this is no big deal, but if you are not using the JSonDriver in your widget.h header file, you really should move in the #include "json_driver.hh" statement to widget.cpp.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.