QmlRegisterType undefined reference
-
Hi there,
I have a problem while implementing a qmlRegisterType.
I'm trying to use the statusbar from jpnurmi (https://github.com/jpnurmi/statusbar). I followed the instruction, but get the following compile error:
../../../Qt5.11.2/5.11.2/android_armv7/include/QtQml/qqml.h:311: error: undefined reference to 'StatusBar::staticMetaObject' ../trunk/3rdparty/Statusbar/statusbar.h:29: error: undefined reference to 'vtable for StatusBar' /Users/wowa/Documents/AndroidTools/android-ndk-r15c/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function (see go/missingkeymethod) ../../../Qt5.11.2/5.11.2/android_armv7/include/QtQml/qqmlprivate.h:98: error: undefined reference to 'StatusBar::StatusBar(QObject*)' ../../../Qt5.11.2/5.11.2/android_armv7/include/QtCore/qmetatype.h:1813: error: undefined reference to 'StatusBar::staticMetaObject' ../../../Qt5.11.2/5.11.2/android_armv7/include/QtCore/qmetatype.h:1448: error: undefined reference to 'StatusBar::staticMetaObject' diaWindowManager.o:diaWindowManager.cpp:vtable for QQmlPrivate::QQmlElement<StatusBar>: error: undefined reference to 'StatusBar::metaObject() const' diaWindowManager.o:diaWindowManager.cpp:vtable for QQmlPrivate::QQmlElement<StatusBar>: error: undefined reference to 'StatusBar::qt_metacast(char const*)' diaWindowManager.o:diaWindowManager.cpp:vtable for QQmlPrivate::QQmlElement<StatusBar>: error: undefined reference to 'StatusBar::qt_metacall(QMetaObject::Call, int, void**)' diaWindowManager.o:diaWindowManager.cpp:typeinfo for QQmlPrivate::QQmlElement<StatusBar>: error: undefined reference to 'typeinfo for StatusBar' collect2: error: ld returned 1 exit status
The statusbar example works fine for me. I can't find the problem. In my app I use the same call like in the example but it does not work.
qmlRegisterType<StatusBar>("StatusBar", 0, 1, "StatusBar");
Maybe someone has an approach for me to handle this error.
Greetings
-
Looks like you have not made a clean build. Remove your build directory, run qmake, then rebuild your app.
-
Did you thrash the build directory and built it again ? Don't just do rebuilt. Delete the build directory completely and rebuild again. Just using the status bar itself gives you this problem ?
-
I completely deleted the build directory.
Yes just the statusbar gives me this problem. When I comment out the qmlRegisterType<StatusBar> line the build finishes successful.
I also registered another class with qml using qmlRegisterType without any problems..
-
This error simply indicates the some old reference of object files are use in compilation. Just to make sure it works, choose different directory checking. Create the Android Project in new directory. Copy the status bar src file. Include pri in your pro file and then compile.
Also can show me your pro file configuration ?
-
I renamed the statusbar directory. Now I get another error.
Undefined symbols for architecture x86_64: "StatusBarPrivate::setColor_sys(QColor const&)", referenced from: StatusBar::setColor(QColor const&) in statusbar.o "StatusBarPrivate::setTheme_sys(StatusBar::Theme)", referenced from: StatusBar::setTheme(StatusBar::Theme) in statusbar.o "StatusBarPrivate::isAvailable_sys()", referenced from: StatusBar::isAvailable() in statusbar.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is a snippet from my .pro file.
TEMPLATE = app TARGET = mymobileapp QT += widgets network svg xml qml quick positioning sensors gui quickcontrols2 CONFIG += c++11 include($$PWD/3rdparty/sbar/statusbar.pri) HEADERS = inc/diaWindowManager.h \ ...
-
I renamed the statusbar directory. Now I get another error.
Undefined symbols for architecture x86_64: "StatusBarPrivate::setColor_sys(QColor const&)", referenced from: StatusBar::setColor(QColor const&) in statusbar.o "StatusBarPrivate::setTheme_sys(StatusBar::Theme)", referenced from: StatusBar::setTheme(StatusBar::Theme) in statusbar.o "StatusBarPrivate::isAvailable_sys()", referenced from: StatusBar::isAvailable() in statusbar.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is a snippet from my .pro file.
TEMPLATE = app TARGET = mymobileapp QT += widgets network svg xml qml quick positioning sensors gui quickcontrols2 CONFIG += c++11 include($$PWD/3rdparty/sbar/statusbar.pri) HEADERS = inc/diaWindowManager.h \ ...