Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QmlRegisterType undefined reference
QtWS25 Last Chance

QmlRegisterType undefined reference

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
8 Posts 4 Posters 3.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wowalive
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Looks like you have not made a clean build. Remove your build directory, run qmake, then rebuild your app.

      (Z(:^

      1 Reply Last reply
      0
      • W Offline
        W Offline
        Wowalive
        wrote on last edited by
        #3

        A complete rebuild didn't solve the problem. I still get the same errors :(

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          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 ?

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • W Offline
            W Offline
            Wowalive
            wrote on last edited by
            #5

            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..

            1 Reply Last reply
            0
            • dheerendraD Offline
              dheerendraD Offline
              dheerendra
              Qt Champions 2022
              wrote on last edited by
              #6

              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 ?

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              1 Reply Last reply
              0
              • W Offline
                W Offline
                Wowalive
                wrote on last edited by
                #7

                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 \
                ...
                
                jsulmJ 1 Reply Last reply
                0
                • W Wowalive

                  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 \
                  ...
                  
                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Wowalive Looks like now you're not building cpp file containing StatusBarPrivate definition. Where is StatusBarPrivate defined and did you add it in your pro file? Also don't forget to run qmake after changing pro file.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved