| Version 3 (modified by , 12 years ago) ( diff ) |
|---|
FAQ (1) -- common compilation errors
MSVC
ComponentBase should be inherited AFTER QObject
Error message
>moc_Component.cpp(63): error C2039: 'staticMetaObject' : is not a member of 'pacpus::ComponentBase' > ComponentBase.h(60) : see declaration of 'pacpus::ComponentBase' >moc_Component.cpp(80): error C2039: 'qt_metacast' : is not a member of 'pacpus::ComponentBase' > ComponentBase.h(60) : see declaration of 'pacpus::ComponentBase' >moc_Component.cpp(85): error C2039: 'qt_metacall' : is not a member of 'pacpus::ComponentBase' > ComponentBase.h(60) : see declaration of 'pacpus::ComponentBase'
Solution
Your class declaration should look like:
class Component
: QObject
, ComponentBase
{
};
Class inheriting from QObject should be moc-ed
Error message
>Component.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const pacpus::Component::staticMetaObject" (?staticMetaObject@Component@pacpus@@2UQMetaObject@@B) >Component.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall pacpus::Component::metaObject(void)const " (?metaObject@Component@pacpus@@UBEPBUQMetaObject@@XZ) >Component.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall pacpus::Component::qt_metacast(char const *)" (?qt_metacast@Component@pacpus@@UAEPAXPBD@Z) >Component.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall pacpus::Component::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Component@pacpus@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
Solution
- Check that you use
moctool on your class, i.e. filemoc_Component.cppis created and linked to the target.
- Add
Component.hto CMake variableMOC_FILES. - Add
${MOC_FILES}to the list of sources used bypacpus_add_libraryorpacpus_add_executable.
Varia
FAQ -- Frequently Asked Questions
Note:
See TracWiki
for help on using the wiki.
