I'm working in a big project with Qt/MinGW/Windows. Recently I changed the places of some of my source files and recompile them, and after some corrections, I began to receive messages such as
(.idata$5+0x0):-1: error: multiple definition of `_imp___ZN9QwtThermo16staticMetaObjectE'
This happens regarding two classes: QwtThermo and QwtPlotPicker in a code where previously there was no such error (remember: I just changed the places of the files in the base folder to some subfolders; no code changed (as far as I remember) and notice that many other Qwt classes are also included and normally used without any compile error; this are the only two ones that are giving me problems).
Now "multiple definition of" is a common error in C++ and I already know how one would normally solve it (many threads, including in StackOverflow, talk about it): one should only declare things in header files while defining them in the .cpp files.
Unfortunately this doesn't seem to be a viable solution this time. Here is what is going on:
- I did a research regarding where this header was being included, and I found no problems. As I sad, it used to compile nicely before.
- The problem would only occur with QwtPlotPicker if I create a subclass of it (doesn't matter if I use it). If I only declare the name of the subclass in the header and define it in the .cpp, then I'm able to compile, but as soon as I start using it (with a member pointer declared in the header), then the compile error "undefined reference for 'vtable for Picker'" appears. So declaring the class in the header and define it in the .cpp doesn't actually help;
- With QwtThermo, if I include the file in the header and ONLY declare a pointer to it (no subclass), then the error start appearing already. This is solved if I only declare the QwtThermo class in my project's header and include QwtThermo's own header in the .cpp file; this way I'm able to declare a member pointer to it and also instantiate the pointer with "new" in the .cpp file inside it's parent class, but as soon as I start using it by calling its methods, the "multiple definition of" starts appearing again.
So as you may see, it would seem that this time it's not just a matter of "declare in the header and define it in the .cpp"; something more is going on. :T
So what could be wrong? Sorry not posting any code, but believe me that everything of interesting of it that could be seen was written already; the only change of posting the code would be by copying more then 5000 lines ^^
I'm glad for any help you can give me :)
Thanks,
EDIT: Here is the code from Qt Creator's "Compile Output":
g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DMGENERALDEFINES_GUI -DMGENERALDEFINES_DEBUG -DMGENERALDEFINES_GENERAL -DQWT_INCLUDED -DDEBUG -DRELEASE -DQT_NO_DEBUG -DQT_NO_DEBUG_OUTPUT -DQT_PRINTSUPPORT_LIB -DQT_MULTIMEDIA_LIB -DQT_WIDGETS_LIB -DQT_SQL_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I. -I"MSHARE_REPO" -I"MSHARE_COMMON" -I"C:\Qt\Qwt-6.1.0\include" -I"C:\Qt\Qt5.2.1\5.2.1\mingw48_32\include" -I"C:\Qt\Qt5.2.1\5.2.1\mingw48_32\include\QtPrintSupport" -I"C:\Qt\Qt5.2.1\5.2.1\mingw48_32\include\QtMultimedia" -I"C:\Qt\Qt5.2.1\5.2.1\mingw48_32\include\QtWidgets" -I"C:\Qt\Qt5.2.1\5.2.1\mingw48_32\include\QtSql" -I"C:\Qt\Qt5.2.1\5.2.1\mingw48_32\include\QtNetwork" -I"C:\Qt\Qt5.2.1\5.2.1\mingw48_32\include\QtGui" -I"C:\Qt\Qt5.2.1\5.2.1\mingw48_32\include\QtCore" -I"build\moc" -I"build\ui" -I"C:\Qt\Qt5.2.1\5.2.1\mingw48_32\mkspecs\win32-g++" -o build\obj\moc_mainwindow.o build\moc\moc_mainwindow.cpp
g++ -Wl,-subsystem,windows -mthreads -o debug\mShare.exe object_script.mShare.Debug -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmaind "D:/Minhas obras/Softwares/mShare Project/mShare/SMTPEmail.dll" -lpsapi C:/Qt/Qwt-6.1.0/lib/qwtd.dll "D:/Minhas obras/Softwares/mShare Project/mShare/../../Classes/mLogger/build/debug/mLogger.dll" "D:/Minhas obras/Softwares/mShare Project/mShare/../mShareLib/build/debug/mShareLib.dll" C:/Qt/Qwt-6.1.0/lib/qwt.dll "D:/Minhas obras/Softwares/mShare Project/mShare/../../Classes/mLogger/build/release/mLogger.dll" "D:/Minhas obras/Softwares/mShare Project/mShare/../mShareLib/build/release/mShareLib.dll" -LC:\Qt\Qt5.2.1\5.2.1\mingw48_32\lib -lQt5PrintSupportd -lQt5Multimediad -lQt5Widgetsd -lQt5Sqld -lQt5Networkd -lQt5Guid -lQt5Cored .\build\obj\icone_res.o
d000171.o:(.idata$5+0x0): multiple definition of `_imp___ZN13QwtPlotPicker16staticMetaObjectE'
d000022.o:(.idata$5+0x0): first defined here
d000171.o:(.idata$6+0x0): multiple definition of `_nm___ZN13QwtPlotPicker16staticMetaObjectE'
d000022.o:(.idata$6+0x0): first defined here
d000172.o:(.idata$5+0x0): multiple definition of `_imp___ZN9QwtThermo16staticMetaObjectE'
d000102.o:(.idata$5+0x0): first defined here
d000172.o:(.idata$6+0x0): multiple definition of `_nm___ZN9QwtThermo16staticMetaObjectE'
Makefile.Debug:246: recipe for target 'debug\mShare.exe' failed
d000102.o:(.idata$6+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: [debug\mShare.exe] Error 1 (ignored)