[SOLVED] vtable issues while building Qt 5 app on OS X (CMake)



  • Hey there,

    Haven't touched Qt for a while and trying to build a Qt 5 application now (marble). Just experienced a little trouble, while shooting another one. MarbleQuickItem is a class over QQuickItem, there was a compiler issue, smth like "QQuickItem.h" is not found.

    I basically added two lines to root CMakeLists.txt:
    @
    find_package(Qt5Quick REQUIRED)
    include_directories( ${Qt5Quick_INCLUDE_DIRS} )
    @

    And it actually worked finally! On the other hand, I still can't understand how it worked on other systems 0_O (w/o Qt5Quick includes). Now I have a compiler output:

    @
    Undefined symbols for architecture x86_64:
    "QQuickItem::itemChange(QQuickItem::ItemChange, QQuickItem::ItemChangeData const&)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::touchEvent(QTouchEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::wheelEvent(QWheelEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::focusInEvent(QFocusEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::updatePolish()", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::dragMoveEvent(QDragMoveEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::focusOutEvent(QFocusEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::keyPressEvent(QKeyEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::dragEnterEvent(QDragEnterEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::dragLeaveEvent(QDragLeaveEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::hoverMoveEvent(QHoverEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::mouseMoveEvent(QMouseEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::geometryChanged(QRectF const&, QRectF const&)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::hoverEnterEvent(QHoverEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::hoverLeaveEvent(QHoverEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::keyReleaseEvent(QKeyEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::mousePressEvent(QMouseEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::inputMethodEvent(QInputMethodEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::mouseUngrabEvent()", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::releaseResources()", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::staticMetaObject", referenced from:
    Marble::AbstractDataPlugin::handleViewportChange(Marble::ViewportParams const*) in AbstractDataPlugin.o
    "QQuickItem::touchUngrabEvent()", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::mouseReleaseEvent(QMouseEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o
    "QQuickItem::childMouseEventFilter(QQuickItem*, QEvent*)", referenced from:
    vtable for Marble::MarbleQuickItem in marblewidget_automoc.o

    ... etc, etc, etc, it actually covers all inherited members.
    @

    Dunno, imho, the bug lies on the ground, but I can't see it any way :. Thanks in advance!


  • Lifetime Qt Champion

    Hi,

    That generally happens when you re-compile a QObject derived class after adding Q_OBJECT but without running qmake so it's marked to be moc'ed. But well it doesn't really make sense in your case… Might be a starting anyway



  • I just noticed that QtC do underline Q_OBJECT in further declaration.

    @
    class MARBLE_EXPORT MarbleQuickItem : public QQuickPaintedItem
    {
    Q_OBJECT

    public:
        MarbleQuickItem(QQuickItem *parent = 0);
    

    @

    It says smth like skip identifier Q_DECL_IMPORT


  • Lifetime Qt Champion

    MARBLE_EXPORT will resolve to Q_DECL_IMPORT depending if you are building the library or using it (have a look at it's implementation)

    Are you using your distribution Qt ?



  • I am using latest Qt from qt-project.org on OS X, building from stock QtC.


  • Lifetime Qt Champion

    Latest official or beta ?

    Which version of OS X/Xcode ? Where did you get Marble ?



  • Qt 5.3.2, official
    OS X 10.9.5
    Xcode 6.0.1
    Git (KDE public git)
    CMake 3.0.2



  • ~SGaist, thanks to Earthwings, I finally came to a solution. It's about linking ${Qt5Quick_LIBRARIES} against the CMake target. I've done only including so far.

    Hate myself for doing such baby mistakes. Thanks.


  • Lifetime Qt Champion

    Well, indeed, the compiler will be really less likely to cooperate if you're missing that :)

    Don't worry, can happen to anybody.

    Since you have it working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.