wiki:FAQ_compilation

Version 5 (modified by Marek Kurdej, 11 years ago) ( diff )

pacpus_plugin

Contents

  1. FAQ (1) -- common compilation errors
    1. MSVC
      1. ComponentBase should be inherited AFTER QObject
        1. Error message
        2. Solution
      2. Class inheriting from QObject should be moc-ed
        1. Error message
        2. Solution
      3. Class should use pacpus_plugin
        1. Error message
        2. Solution
      4. addInputs() / addOutputs can be used only in a class derived from QObject
        1. Error message
        2. Solution
    2. Varia

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 moc tool on your class, i.e. file moc_Component.cpp is created and linked to the target.
  1. Add Component.h to CMake variable MOC_FILES.
  2. Add ${MOC_FILES} to the list of sources used by pacpus_add_library or pacpus_add_executable.

Class should use pacpus_plugin

Error message

Similar to the previous one, but concerning ComponentPlugin.

Solution

  • Check that you use pacpus_plugin CMake macro and that generated files ${PLUGIN_CPP} and ${PLUGIN_HDR} are compiled and correspoding objects linked to the target.

addInputs() / addOutputs can be used only in a class derived from QObject

Error message

>C:\Program Files (x86)\Pacpus\include\Pacpus/kernel/InputOutputInterface.h(21): error C2664: 'pacpus::InputInterfaceBase::InputInterfaceBase(QString,pacpus::ComponentBase *,QObject *)' : cannot convert parameter 3 from 'pacpus::LMOComponent *' to 'QObject *'
>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
>          C:\Program Files (x86)\Pacpus\include\Pacpus/kernel/InputOutputInterface.h(18) : while compiling class template member function 'pacpus::InputInterface<T,C>::InputInterface(QString,C *,void (__thiscall pacpus::Component::* )(const T &))'
>          with
>          [
>              T=pacpus::___,
>              C=pacpus::Component
>          ]
>          C:\Program Files (x86)\Pacpus\include\Pacpus/kernel/ComponentBase.h(150) : see reference to class template instantiation 'pacpus::InputInterface<T,C>' being compiled
>          with
>          [
>              T=pacpus::___,
>              C=pacpus::Component
>          ]
>          ..\..\..\cityvip-2.0-beta1\src\LMOComponent\Component.cpp(44) : see reference to function template instantiation 'void pacpus::ComponentBase::addInput<pacpus::___,pacpus::Component,void(__thiscall pacpus::Component::* )(const pacpus::___ &)>(const char *,Function)' being compiled
>          with
>          [
>              Function=void (__thiscall pacpus::Component::* )(const pacpus::___ &)
>          ]

Solution

Inherit your class from QObject.

Varia

FAQ -- Frequently Asked Questions

Note: See TracWiki for help on using the wiki.