Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Defined but unused slot throwing up undefined symbol exception
Forum Updated to NodeBB v4.3 + New Features

Defined but unused slot throwing up undefined symbol exception

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 751 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.
  • AritzA Offline
    AritzA Offline
    Aritz
    wrote on last edited by Aritz
    #1

    We have an application running with Qt 5.12.6 version in x64 platforms and we're porting it to Qt 5.13.2 version to run in an ARM imx8 board. We're compiling the code in an Azure Pipeline and using cross-compilation for generating the ARM binaries.

    For both cases the code compiles well, however, there are some defined but unused slots. This gives no problem in the x64 computer, but throws undefined symbol exception in the ARM board at runtime.

    We managed to fix it removing the unused slot declarations, but, is there any way to detect that there are unused slot declarations at compile time? It's interesting for us to know it at compile time, because since we're cross-compiling it's not possible to make a boot-up check in the compile environment.

    jsulmJ 1 Reply Last reply
    0
    • AritzA Aritz

      We have an application running with Qt 5.12.6 version in x64 platforms and we're porting it to Qt 5.13.2 version to run in an ARM imx8 board. We're compiling the code in an Azure Pipeline and using cross-compilation for generating the ARM binaries.

      For both cases the code compiles well, however, there are some defined but unused slots. This gives no problem in the x64 computer, but throws undefined symbol exception in the ARM board at runtime.

      We managed to fix it removing the unused slot declarations, but, is there any way to detect that there are unused slot declarations at compile time? It's interesting for us to know it at compile time, because since we're cross-compiling it's not possible to make a boot-up check in the compile environment.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Aritz said in Defined but unused slot throwing up undefined symbol exception:

      undefined symbol exception in the ARM board at runtime

      Do you load libraries at runtime?
      Usually you get "undefined symbol" linker errors already at build time.

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

      1 Reply Last reply
      0
      • AritzA Offline
        AritzA Offline
        Aritz
        wrote on last edited by
        #3

        It is a plugin which we load at runtime. Could this be related?

        jsulmJ 1 Reply Last reply
        0
        • AritzA Aritz

          It is a plugin which we load at runtime. Could this be related?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Aritz said in Defined but unused slot throwing up undefined symbol exception:

          Could this be related?

          Yes, if the lib containing the slot is not loaded.

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

          1 Reply Last reply
          0
          • AritzA Offline
            AritzA Offline
            Aritz
            wrote on last edited by Aritz
            #5

            The error is thrown from the plugin code, but the header file containing the public slot definition is in the plugin itself. But there's no code in the plugin using that slot definition.

            1 Reply Last reply
            0
            • Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Aritz said in Defined but unused slot throwing up undefined symbol exception:

              But there's no code in the plugin using it.

              You're aware that moc generates code for every slot so this function is referenced?

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              AritzA 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                @Aritz said in Defined but unused slot throwing up undefined symbol exception:

                But there's no code in the plugin using it.

                You're aware that moc generates code for every slot so this function is referenced?

                AritzA Offline
                AritzA Offline
                Aritz
                wrote on last edited by
                #7

                @Christian-Ehrlicher No, I wasn't aware of that, but it makes sense. Anyway, no .moc files are generated in my build directory. From the docs:

                "If you use qmake to create your makefiles, build rules will be included that call the moc when required, so you will not need to use the moc directly."

                Shouldn't qmake deal with it directly or maybe do I need an extra flag for it? Basically this is what compiles my project:

                mkdir $(Agent.BuildDirectory)/s/my_project/buildDir
                cd $(Agent.BuildDirectory)/s/my_project/buildDir
                qmake ../my_project.pro -spec linux-oe-g++
                make qmake_all
                make
                
                1 Reply Last reply
                0
                • Christian EhrlicherC Online
                  Christian EhrlicherC Online
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  I don't see what qmake or moc does wrong here. You defined a slot in your class but not implemented it as it seems. The code moc creates references this function (so it can be called via signals/slots and others) so you get an undefined reference.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  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