Error detected in generated moc files during compilation
-
I am having some issue with the autogenerated code by QT's Q_MOC_OUTPUT_REVISION). Essentially when I click to build, I get the errors below. I am not entirely sure what it all means and I have been busy for the past hour trying to figure out what it means but I would appreciate a more informed explanation of what the errors mean and how I can go about get rid of them.
@class Product: public QObject
{
Q_OBJECT
Q_PROPERTY(QString _productid READ _productid WRITE _productid)
Q_PROPERTY(QString _productcategoryid READ _productcategoryid WRITE _productcategoryid)
Q_PROPERTY(QString _name READ _name WRITE _name)
Q_PROPERTY(Productcontent * contents READ contents WRITE contents)//dynamic allocation of space for contents
Q_PROPERTY(QString _productimagepath READ _productimagepath WRITE _productimagepath)
Q_PROPERTY(QString _producticonpath READ _producticonpath WRITE _producticonpath )
Q_PROPERTY(QString _productPrice READ _productPrice WRITE _productPrice )//since this does not change for each product, no need resending it each time
public:
static const string _xmldocpath; static const string rootitemname; static const string tagname; QString _productid; QString _name; QString _productcategoryid; QString _productimagepath; QString _producticonpath; QString _productPrice; Product(); // const std::string &getfilepath(); // const std::string &getproducttagname(); // bool UpdateProductData(string id); Q_INVOKABLE int FindProductByID(QString id); ~Product();
public slots:
signals:
};
@The following error results. I have no idea how to disect this one. Any help will be greatly appreciated.
@ debug\moc_product.cpp: In member function 'virtual int Productcontent::qt_metacall(QMetaObject::Call, int, void**)':
debug\moc_product.cpp:77: error: no match for call to '(QString) ()'
debug\moc_product.cpp:78: error: no match for call to '(QString) ()'
debug\moc_product.cpp:84: error: no match for call to '(QString) (QString&)'
debug\moc_product.cpp:85: error: no match for call to '(QString) (QString&)'
debug\moc_product.cpp: In member function 'virtual int Product::qt_metacall(QMetaObject::Call, int, void**)':
debug\moc_product.cpp:179: error: no match for call to '(QString) ()'
debug\moc_product.cpp:180: error: no match for call to '(QString) ()'
debug\moc_product.cpp:181: error: no match for call to '(QString) ()'
debug\moc_product.cpp:182: error: 'contents' was not declared in this scope
debug\moc_product.cpp:183: error: no match for call to '(QString) ()'
debug\moc_product.cpp:184: error: no match for call to '(QString) ()'
debug\moc_product.cpp:185: error: no match for call to '(QString) ()'
debug\moc_product.cpp:191: error: no match for call to '(QString) (QString&)'
debug\moc_product.cpp:192: error: no match for call to '(QString) (QString&)'
debug\moc_product.cpp:193: error: no match for call to '(QString) (QString&)'
debug\moc_product.cpp:194: error: 'contents' was not declared in this scope
debug\moc_product.cpp:195: error: no match for call to '(QString) (QString&)'
debug\moc_product.cpp:196: error: no match for call to '(QString) (QString&)'
debug\moc_product.cpp:197: error: no match for call to '(QString) (QString&)'
mingw32-make.exe[1]: Leaving directory `C:/Users/minel/QMLUIProject_One-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug'
mingw32-make.exe[1]: *** [debug/moc_product.o] Error 1
mingw32-make.exe: *** [debug] Error 2
17:45:04: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
Error while building project QMLUIProject_One (target: Desktop)
When executing build step 'Make'@ -
You need to define proper setter and getter methods for your properties. Exposing them as public members is not going to work, and is a bad idea in any case. So, instead of:
@
Q_PROPERTY(QString _productid READ _productid WRITE _productid)public:
QString _productid;
@you do
@
Q_PROPERTY(QString productid READ productid WRITE setProductid)public:
QString productId() const {return m_productId;}
void setProductId(const QString& newId) {m_productId = newId;}private:
QString m_productId;
@ -
Thanks Andre. That took care of that but Now I am running into the linker problem, and I am wondering if it is related with the same issue
@:-1: error: collect2: ld returned 1 exit status@
How you please help me with this?
-
Upon compiling my code, I get the error below. I am not entirely sure why I am getting a linker error of this kind of what it means. Below is the compile output
@20:41:13: Running build steps for project QMLUIProject_One...
20:41:13: Configuration unchanged, skipping qmake step.
20:41:13: Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Debug
mingw32-make.exe[1]: Entering directoryC:/Users/TavioIntl/QMLUIProject_One-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug' g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_DECLARATIVE_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtXml" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtDeclarative" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"..\QMLUIProject_One\qmlapplicationviewer" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"..\QMLUIProject_One" -I"." -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\usercontext.o ..\QMLUIProject_One\usercontext.cpp C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_DECLARATIVE_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtXml" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtDeclarative" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"..\QMLUIProject_One\qmlapplicationviewer" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"..\QMLUIProject_One" -I"." -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -D__GNUC__ -DWIN32 ..\QMLUIProject_One\usercontext.h -o debug\moc_usercontext.cpp g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_DECLARATIVE_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtXml" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtDeclarative" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"..\QMLUIProject_One\qmlapplicationviewer" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"..\QMLUIProject_One" -I"." -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\moc_usercontext.o debug\moc_usercontext.cpp g++ -mthreads -Wl,-subsystem,windows -o debug\QMLUIProject_One.exe debug/main.o debug/product.o debug/ProcessRequests.o debug/usercontext.o debug/qmlapplicationviewer.o debug/moc_qmlapplicationviewer.o debug/moc_product.o debug/moc_usercontext.o -L"c:\QtSDK\Desktop\Qt\4.7.4\mingw\lib" -lmingw32 -lqtmaind -lQtDeclaratived4 -lQtXmld4 -lQtGuid4 -lQtCored4 -LC:\OpenSSL-Win32_full\lib mingw32-make.exe[1]: Leaving directory
C:/Users/TavioIntl/QMLUIProject_One-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug'
debug/usercontext.o:usercontext.cpp:(.text$_ZNK11UserContext7tagnameEv[UserContext::tagname() const]+0x10): undefined reference toUserContext::_tagname' debug/usercontext.o:usercontext.cpp:(.text$_ZNK11UserContext10xmldocpathEv[UserContext::xmldocpath() const]+0x10): undefined reference to
UserContext::_xmldocpath'
debug/moc_product.o:moc_product.cpp:(.rdata$_ZTV14Productcontent[vtable for Productcontent]+0x14): undefined reference toProductcontent::~Productcontent()' debug/moc_product.o:moc_product.cpp:(.rdata$_ZTV14Productcontent[vtable for Productcontent]+0x18): undefined reference to
Productcontent::~Productcontent()'
debug/moc_usercontext.o:moc_usercontext.cpp:(.rdata$_ZTV11UserContext[vtable for UserContext]+0x14): undefined reference toUserContext::~UserContext()' debug/moc_usercontext.o:moc_usercontext.cpp:(.rdata$_ZTV11UserContext[vtable for UserContext]+0x18): undefined reference to
UserContext::~UserContext()'
collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [debug\QMLUIProject_One.exe] Error 1
mingw32-make.exe: *** [debug] Error 2
20:41:30: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
Error while building project QMLUIProject_One (target: Desktop)
When executing build step 'Make'@This is the error message
@:-1: error: collect2: ld returned 1 exit status@
Please help me tackle this problem. Thanks in advance
-
Not if you don't give more details. You only show the last line of the error, while the important details are what is above that. Anyway, often if you get issues to someting Q_OBJECT related, run qmake again.
-
You are missing the destructor for <code>Productcontent</code> and <code>UserContext</code> and you are missing the definition for <code>UserContext::_tagname</code>.
-
The error messages say it all :-) Use c++filt to decode the mangled names, that will tell you what is missing in plain C++.
-
[quote author="Kobojunkie" date="1328480112"]Thanks Andre. That took care of that but Now I am running into the linker problem, and I am wondering if it is related with the same issue
@:-1: error: collect2: ld returned 1 exit status@
How you please help me with this? [/quote]
This message is only the result reported by the linker. The actual symbols it was missing are further up in the build output.
-
-
I merged the separate topics as both contained the same question, and moved it from the Qt Quick to General and Desktop as it was unrelated to QML/Quick.