Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Strange 'undefined reference' link errors on Ubuntu static build



  • I have a cmake built QML app that builds and runs fine on MacOS and Windows 10, but fails to build on Ubuntu 16.04 and 18.04.

    I'm building against a static build of 5.15.2 which I built from source. I have also tried 5.14.2 and it exhibits the same problem, and I have tried on 3 different machines.

    It feels like a configuration issue, or some problem with picking up old versions of libraries or something, but the examples that are built as part of the Qt installation, including the QtQuickControl2 apps like gallery build and run fine. They are obviously using the qmake build whereas I'm using cmake, I've tried examining the make output using VERBOSE=1 and I can't see any obvious missing link library or whatever.

    I'm working on creating a minimal example to reproduce the problem, but in the meantime
    the issue seems to revolve around QtQuickControls2. My app will build and run fine if I have a minimal QML, but as soon as I add import QtQuick.Controls 2.15 I get all these errors.

    I have the relevant target_link_libraries and Q_IMPORT_PLUGIN directives - as noted above the exact same repo builds and runs fine on MacOS and Windows running against static 5.15.2 Qt builds.

    Does anybody have any clues off the top of their heads?

    The link errors are:

    /home/nuc/dev/qt-static-release/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.a(qtquickcontrols2plugin.o): In function `QtQuickControls2Plugin::~QtQuickControls2Plugin()':
    qtquickcontrols2plugin.cpp:(.text._ZN22QtQuickControls2PluginD2Ev+0x19): undefined reference to `QQuickStylePrivate::reset()'
    qtquickcontrols2plugin.cpp:(.text._ZN22QtQuickControls2PluginD2Ev+0x22): undefined reference to `QQuickStylePlugin::~QQuickStylePlugin()'
    /home/nuc/dev/qt-static-release/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.a(qtquickcontrols2plugin.o): In function `QtQuickControls2Plugin::~QtQuickControls2Plugin()':
    qtquickcontrols2plugin.cpp:(.text._ZN22QtQuickControls2PluginD0Ev+0x19): undefined reference to `QQuickStylePrivate::reset()'
    qtquickcontrols2plugin.cpp:(.text._ZN22QtQuickControls2PluginD0Ev+0x21): undefined reference to `QQuickStylePlugin::~QQuickStylePlugin()'
    /home/nuc/dev/qt-static-release/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.a(qtquickcontrols2plugin.o): In function `QtQuickControls2Plugin::registerTypes(char const*)::{lambda(QQmlEngine*, QJSEngine*)#61}::_FUN(QQmlEngine*, QJSEngine*)':
    qtquickcontrols2plugin.cpp:(.text._ZZN22QtQuickControls2Plugin13registerTypesEPKcENUlP10QQmlEngineP9QJSEngineE59_4_FUNES3_S5_+0x14): undefined reference to `QQuickColor::QQuickColor(QObject*)'
    /home/nuc/dev/qt-static-release/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.a(qtquickcontrols2plugin.o): In function `void QQmlPrivate::createInto<QQuickPaddedRectangle>(void*)':
    qtquickcontrols2plugin.cpp:(.text._ZN11QQmlPrivate10createIntoI21QQuickPaddedRectangleEEvPv[_ZN11QQmlPrivate10createIntoI21QQuickPaddedRectangleEEvPv]+0x7): undefined reference to `QQuickPaddedRectangle::QQuickPaddedRectangle(QQuickItem*)'
    /home/nuc/dev/qt-static-release/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.a(qtquickcontrols2plugin.o): In function `void QQmlPrivate::createInto<QQuickTumblerView>(void*)':
    qtquickcontrols2plugin.cpp:(.text._ZN11QQmlPrivate10createIntoI17QQuickTumblerViewEEvPv[_ZN11QQmlPrivate10createIntoI17QQuickTumblerViewEEvPv]+0x7): undefined reference to `QQuickTumblerView::QQuickTumblerView(QQuickItem*)'
    /home/nuc/dev/qt-static-release/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.a(qtquickcontrols2plugin.o): In function `QQmlPrivate::QQmlElement<QQuickTumblerView>::~QQmlElement()':
    qtquickcontrols2plugin.cpp:(.text._ZN11QQmlPrivate11QQmlElementI17QQuickTumblerViewED2Ev[_ZN11QQmlPrivate11QQmlElementI17QQuickTumblerViewED5Ev]+0x20): undefined reference to `vtable for QQuickTumblerView'
    /home/nuc/dev/qt-static-release/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.a(qtquickcontrols2plugin.o): In function `non-virtual thunk to QQmlPrivate::QQmlElement<QQuickTumblerView>::~QQmlElement()':
    qtquickcontrols2plugin.cpp:(.text._ZN11QQmlPrivate11QQmlElementI17QQuickTumblerViewED2Ev[_ZN11QQmlPrivate11QQmlElementI17QQuickTumblerViewED5Ev]+0x7c): undefined reference to `vtable for QQuickTumblerView'
    /home/nuc/dev/qt-static-release/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.a(qtquickcontrols2plugin.o): In function `void QQmlPrivate::createInto<QQuickClippedText>(void*)':
    qtquickcontrols2plugin.cpp:(.text._ZN11QQmlPrivate10createIntoI17QQuickClippedTextEEvPv[_ZN11QQmlPrivate10createIntoI17QQuickClippedTextEEvPv]+0x7): undefined reference to `QQuickClippedText::QQuickClippedText(QQuickItem*)'
    /home/nuc/dev/qt-static-release/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.a(qtquickcontrols2plugin.o): In function `QQmlPrivate::QQmlElement<QQuickClippedText>::~QQmlElement()':
    qtquickcontrols2plugin.cpp:(.text._ZN11QQmlPrivate11QQmlElementI17QQuickClippedTextED2Ev[_ZN11QQmlPrivate11QQmlElementI17QQuickClippedTextED5Ev]+0x20): undefined reference to `vtable for QQuickClippedText'
    /home/nuc/dev/qt-static-release/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.a(qtquickcontrols2plugin.o): In function `non-virtual thunk to QQmlPrivate::QQmlElement<QQuickClippedText>::~QQmlElement()':
    qtquickcontrols2plugin.cpp:(.text._ZN11QQmlPrivate11QQmlElementI17QQuickClippedTextED2Ev[_ZN11QQmlPrivate11QQmlElementI17QQuickClippedTextED5Ev]+0x6c): undefined reference to `vtable for QQuickClippedText'
    /home/nuc/dev/qt-static-release/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.a(qtquickcontrols2plugin.o): In function `QQmlPrivate::QQmlElement<QQuickPlaceholderText>::~QQmlElement()':
    


  • OK, more clearly stated:

    Why would I be getting 'undefined reference' to 'private' Qt classes (e.g. QQuickStylePrivate::reset()) when linking with libqtquickcontrols2plugin.a?

    I have the following included in target_link_libararies:

    target_link_libraries(
        ${PROJECT_NAME}
        PRIVATE
        Qt5::Core
        Qt5::Network
        Qt5::Qml
        Qt5::Quick
        Qt5::QuickControls2
        Qt5::WebChannel
         ...
    )
    

    What library could be missing that includes these symbols?

    Any insights much appreciated...


Log in to reply