wiki:FAQ_compilation

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

CMake error when no WINSDK_LIB is set

Contents

  1. FAQ (1) -- common compilation errors
    1. CMake
      1. [Windows] [Qt5] Qt5 needs OpenGL
        1. Error message
        2. Solution
    2. 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
    3. Varia

FAQ (1) -- common compilation errors

CMake

[Windows] [Qt5] Qt5 needs OpenGL

Error message

CMake Error at C:/Qt/Qt5.1.0/5.1.0/msvc2010_opengl/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:16 (message):
  Failed to find "glu32" in "".
Call Stack (most recent call first):
  C:/Qt/Qt5.1.0/5.1.0/msvc2010_opengl/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:50 (_qt5gui_find_extra_libs)
  C:/Qt/Qt5.1.0/5.1.0/msvc2010_opengl/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:127 (include)
  C:/Qt/Qt5.1.0/5.1.0/msvc2010_opengl/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake:83 (find_package)
  cmake/PacpusDependencies.cmake:35 (find_package)
  CMakeLists.txt:51 (include)

Solution

As described here, you should tell CMake the path to Windows SDK libraries. Add environment variable WINSDK_LIB and set it to the path containing GlU32.Lib, e.g.:

c:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86

If you do not have Windows SDK installed, look at its download page.

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.