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. undefined reference to `vtable for shutdown'
Forum Updated to NodeBB v4.3 + New Features

undefined reference to `vtable for shutdown'

Scheduled Pinned Locked Moved Solved General and Desktop
60 Posts 6 Posters 8.5k Views 2 Watching
  • 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.
  • S Offline
    S Offline
    SPlatten
    wrote on 31 May 2022, 11:40 last edited by SPlatten
    #1

    I am working on a project using Qt 4.8.4, the revision of Qt is something I have no control over. I have added a class one of the libraries which are built with cmake, here is the prototype:

    shutdown.h:

    #ifndef SHUTDOWN_H
    #define SHUTDOWN_H
    
    #include <QApplication>
    #include <QDesktopWidget>
    #include <QMainWindow>
    
    namespace Ui {
        class shutdown;
    }
    
    class shutdown : public QMainWindow {
        Q_OBJECT
    
    public:
        explicit shutdown(const char* cpszText, QWidget* pParent = 0);
        ~shutdown();
    
    private:
        Ui::shutdown* ui;
    };
    #endif // SHUTDOWN_H
    

    shutdown.cc:

    #include "shutdown.h"
    #include "ui_shutdown.h"
    
    shutdown::shutdown(const char* cpszText, QWidget* pParent) :
        QMainWindow(pParent),
        ui(new Ui::shutdown) {
        ui->setupUi(this);
        if ( cpszText ) {
            ui->plblText->setText(cpszText);
        }
    }
    
    shutdown::~shutdown() {
        delete ui;
    }
    

    I've checked CMakeLists.txt which includes the CC file, however when build completes I get:

    ../../(shutdown.cc.o): In function `shutdown::shutdown(char const*, QWidget*)':
    shutdown.cc: (.text+0x3a): undefined reference to `vtable for shutdown'
    shutdown.cc: (.text+0x41): undefined reference to `vtable for shutdown'
    ../../(shutdown.cc.o): In function `shutdown::~shutdown()':
    shutdown.cc: (.text+0x4cd): undefined reference to `vtable for shutdown'
    shutdown.cc: (.text+0x4d4): undefined reference to `vtable for shutdown'
    collect2: ld returned 1 exit status
    make[2]: *** [file name] Error 1
    make[2] Leaving directory 'location'
    make[1] ** [filename.dir/all] Error 2
    make[1] Leaving directory 'location'
    make: *** [all] Error 2
    

    Kind Regards,
    Sy

    J 2 Replies Last reply 31 May 2022, 11:58
    0
    • S Offline
      S Offline
      SPlatten
      wrote on 1 Jun 2022, 07:48 last edited by
      #56

      I finally found and fixed the issue, which turned out to be not code related at all. The problem was in the CMakeLists.txt file, the build structure here is over complicated and there were two instances of the same file in a slightly different folder structure, unfortunately I had been editing the wrong file, having realised this and moved onto the correct file, everything is now A ok!

      Kind Regards,
      Sy

      C 1 Reply Last reply 1 Jun 2022, 14:39
      0
      • S SPlatten
        31 May 2022, 11:40

        I am working on a project using Qt 4.8.4, the revision of Qt is something I have no control over. I have added a class one of the libraries which are built with cmake, here is the prototype:

        shutdown.h:

        #ifndef SHUTDOWN_H
        #define SHUTDOWN_H
        
        #include <QApplication>
        #include <QDesktopWidget>
        #include <QMainWindow>
        
        namespace Ui {
            class shutdown;
        }
        
        class shutdown : public QMainWindow {
            Q_OBJECT
        
        public:
            explicit shutdown(const char* cpszText, QWidget* pParent = 0);
            ~shutdown();
        
        private:
            Ui::shutdown* ui;
        };
        #endif // SHUTDOWN_H
        

        shutdown.cc:

        #include "shutdown.h"
        #include "ui_shutdown.h"
        
        shutdown::shutdown(const char* cpszText, QWidget* pParent) :
            QMainWindow(pParent),
            ui(new Ui::shutdown) {
            ui->setupUi(this);
            if ( cpszText ) {
                ui->plblText->setText(cpszText);
            }
        }
        
        shutdown::~shutdown() {
            delete ui;
        }
        

        I've checked CMakeLists.txt which includes the CC file, however when build completes I get:

        ../../(shutdown.cc.o): In function `shutdown::shutdown(char const*, QWidget*)':
        shutdown.cc: (.text+0x3a): undefined reference to `vtable for shutdown'
        shutdown.cc: (.text+0x41): undefined reference to `vtable for shutdown'
        ../../(shutdown.cc.o): In function `shutdown::~shutdown()':
        shutdown.cc: (.text+0x4cd): undefined reference to `vtable for shutdown'
        shutdown.cc: (.text+0x4d4): undefined reference to `vtable for shutdown'
        collect2: ld returned 1 exit status
        make[2]: *** [file name] Error 1
        make[2] Leaving directory 'location'
        make[1] ** [filename.dir/all] Error 2
        make[1] Leaving directory 'location'
        make: *** [all] Error 2
        
        J Offline
        J Offline
        JonB
        wrote on 31 May 2022, 11:58 last edited by
        #2

        @SPlatten
        First do a complete, utter rebuild --- i.e. delete all the previously generated object files --- and see whether still an issue....

        S 1 Reply Last reply 31 May 2022, 12:02
        0
        • J JonB
          31 May 2022, 11:58

          @SPlatten
          First do a complete, utter rebuild --- i.e. delete all the previously generated object files --- and see whether still an issue....

          S Offline
          S Offline
          SPlatten
          wrote on 31 May 2022, 12:02 last edited by
          #3

          @JonB , done, many times:

          make clean
          cmake ${variable}
          make
          

          Kind Regards,
          Sy

          J 1 Reply Last reply 31 May 2022, 12:05
          0
          • S SPlatten
            31 May 2022, 12:02

            @JonB , done, many times:

            make clean
            cmake ${variable}
            make
            
            J Offline
            J Offline
            J.Hilk
            Moderators
            wrote on 31 May 2022, 12:05 last edited by
            #4

            @SPlatten

            delete all the previously generated

            clean is not infallible, actually delete the shadow build folder.


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            S 1 Reply Last reply 31 May 2022, 12:06
            1
            • J J.Hilk
              31 May 2022, 12:05

              @SPlatten

              delete all the previously generated

              clean is not infallible, actually delete the shadow build folder.

              S Offline
              S Offline
              SPlatten
              wrote on 31 May 2022, 12:06 last edited by
              #5

              @J-Hilk , how do I do that?

              Kind Regards,
              Sy

              J 1 Reply Last reply 31 May 2022, 12:07
              0
              • S SPlatten
                31 May 2022, 12:06

                @J-Hilk , how do I do that?

                J Offline
                J Offline
                J.Hilk
                Moderators
                wrote on 31 May 2022, 12:07 last edited by
                #6

                @SPlatten selected it in the file explorer of your choice, and press delete on your keyboard


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                S 1 Reply Last reply 31 May 2022, 12:07
                0
                • J J.Hilk
                  31 May 2022, 12:07

                  @SPlatten selected it in the file explorer of your choice, and press delete on your keyboard

                  S Offline
                  S Offline
                  SPlatten
                  wrote on 31 May 2022, 12:07 last edited by
                  #7

                  @J-Hilk , thank you, how do I identify its where abouts?

                  Kind Regards,
                  Sy

                  J 1 Reply Last reply 31 May 2022, 12:08
                  0
                  • S SPlatten
                    31 May 2022, 12:07

                    @J-Hilk , thank you, how do I identify its where abouts?

                    J Offline
                    J Offline
                    J.Hilk
                    Moderators
                    wrote on 31 May 2022, 12:08 last edited by J.Hilk
                    #8

                    @SPlatten if you're using QtCreator, in the project settings tab, its usually parallel to your source folder


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    S 1 Reply Last reply 31 May 2022, 12:09
                    0
                    • J J.Hilk
                      31 May 2022, 12:08

                      @SPlatten if you're using QtCreator, in the project settings tab, its usually parallel to your source folder

                      S Offline
                      S Offline
                      SPlatten
                      wrote on 31 May 2022, 12:09 last edited by SPlatten
                      #9

                      @J-Hilk , unfortunately not, the build process is entirely using cmake. I've just renamed the build folder and then started off the build again with a new build folder, all the object files were in subfolders of the build folder.

                      Kind Regards,
                      Sy

                      J 1 Reply Last reply 31 May 2022, 12:12
                      0
                      • S SPlatten
                        31 May 2022, 12:09

                        @J-Hilk , unfortunately not, the build process is entirely using cmake. I've just renamed the build folder and then started off the build again with a new build folder, all the object files were in subfolders of the build folder.

                        J Offline
                        J Offline
                        J.Hilk
                        Moderators
                        wrote on 31 May 2022, 12:12 last edited by
                        #10

                        @SPlatten said in undefined reference to &#x60;vtable for shutdown':

                        @J-Hilk , unfortunately not, the build process is entirely using cmake.

                        qmake or cmake make no difference here, build directory is what you're looking for

                        e3a5ac17-1669-40a7-b35e-8aaafce58db4-image.png


                        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                        Q: What's that?
                        A: It's blue light.
                        Q: What does it do?
                        A: It turns blue.

                        S 1 Reply Last reply 31 May 2022, 12:13
                        0
                        • J J.Hilk
                          31 May 2022, 12:12

                          @SPlatten said in undefined reference to &#x60;vtable for shutdown':

                          @J-Hilk , unfortunately not, the build process is entirely using cmake.

                          qmake or cmake make no difference here, build directory is what you're looking for

                          e3a5ac17-1669-40a7-b35e-8aaafce58db4-image.png

                          S Offline
                          S Offline
                          SPlatten
                          wrote on 31 May 2022, 12:13 last edited by
                          #11

                          @J-Hilk , build just completed in new folder with exactly the same results.

                          Kind Regards,
                          Sy

                          J 1 Reply Last reply 31 May 2022, 12:16
                          0
                          • S SPlatten
                            31 May 2022, 12:13

                            @J-Hilk , build just completed in new folder with exactly the same results.

                            J Offline
                            J Offline
                            J.Hilk
                            Moderators
                            wrote on 31 May 2022, 12:16 last edited by J.Hilk
                            #12

                            @SPlatten ok, one point less to check, very unusual

                            ok, try adding virtual to your destructor declaration.

                            did you post the whole class?
                            are there any other functions, virtual or not, in there?


                            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                            Q: What's that?
                            A: It's blue light.
                            Q: What does it do?
                            A: It turns blue.

                            S 2 Replies Last reply 31 May 2022, 12:19
                            0
                            • J J.Hilk
                              31 May 2022, 12:16

                              @SPlatten ok, one point less to check, very unusual

                              ok, try adding virtual to your destructor declaration.

                              did you post the whole class?
                              are there any other functions, virtual or not, in there?

                              S Offline
                              S Offline
                              SPlatten
                              wrote on 31 May 2022, 12:19 last edited by
                              #13

                              @J-Hilk . that was the entire class, I've added virtual to the destructor prototype, rebuilding now.

                              Kind Regards,
                              Sy

                              J 1 Reply Last reply 31 May 2022, 12:27
                              0
                              • J J.Hilk
                                31 May 2022, 12:16

                                @SPlatten ok, one point less to check, very unusual

                                ok, try adding virtual to your destructor declaration.

                                did you post the whole class?
                                are there any other functions, virtual or not, in there?

                                S Offline
                                S Offline
                                SPlatten
                                wrote on 31 May 2022, 12:25 last edited by
                                #14

                                @J-Hilk, Exactly the same results.

                                Kind Regards,
                                Sy

                                1 Reply Last reply
                                0
                                • S SPlatten
                                  31 May 2022, 12:19

                                  @J-Hilk . that was the entire class, I've added virtual to the destructor prototype, rebuilding now.

                                  J Offline
                                  J Offline
                                  J.Hilk
                                  Moderators
                                  wrote on 31 May 2022, 12:27 last edited by J.Hilk
                                  #15

                                  @SPlatten did you make changes in your CMakeLists.txt ?

                                  I assume you have
                                  set(CMAKE_AUTOUIC ON)
                                  set(CMAKE_AUTOMOC ON)
                                  set(CMAKE_AUTORCC ON)
                                  set (CMAKE_INCLUDE_CURRENT_DIR ON)

                                  in it ?

                                  and
                                  set(PROJECT_SOURCES ....)contains your new class ?
                                  as well as
                                  qt5_wrap_cpp qt4_wrap_cpp() (I think that was needed for older version ?)


                                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                                  Q: What's that?
                                  A: It's blue light.
                                  Q: What does it do?
                                  A: It turns blue.

                                  S 2 Replies Last reply 31 May 2022, 12:31
                                  0
                                  • J J.Hilk
                                    31 May 2022, 12:27

                                    @SPlatten did you make changes in your CMakeLists.txt ?

                                    I assume you have
                                    set(CMAKE_AUTOUIC ON)
                                    set(CMAKE_AUTOMOC ON)
                                    set(CMAKE_AUTORCC ON)
                                    set (CMAKE_INCLUDE_CURRENT_DIR ON)

                                    in it ?

                                    and
                                    set(PROJECT_SOURCES ....)contains your new class ?
                                    as well as
                                    qt5_wrap_cpp qt4_wrap_cpp() (I think that was needed for older version ?)

                                    S Offline
                                    S Offline
                                    SPlatten
                                    wrote on 31 May 2022, 12:31 last edited by
                                    #16

                                    @J-Hilk , I've added the set calls from your post to the make file, the qt4 bits that I did have:

                                    find_package(Qt4 REQUIRED)
                                    include(${QT_USE_FILE})
                                    foreach(loop_var ${QT_LIBRARIES})
                                      string(REPLACE lib64 lib32 loop_var ${loop_var})
                                      set(QT_LIBRARIES_32 ${QT_LIBRARIES_32} ${loop_var})
                                    endforeach(loop_var)
                                    qt4_wrap_ui(UI_HEADERS ${FORMS})
                                    qt4_wrap_cpp(MOC_SRCS ${HEADERS})
                                    

                                    Kind Regards,
                                    Sy

                                    1 Reply Last reply
                                    0
                                    • J J.Hilk
                                      31 May 2022, 12:27

                                      @SPlatten did you make changes in your CMakeLists.txt ?

                                      I assume you have
                                      set(CMAKE_AUTOUIC ON)
                                      set(CMAKE_AUTOMOC ON)
                                      set(CMAKE_AUTORCC ON)
                                      set (CMAKE_INCLUDE_CURRENT_DIR ON)

                                      in it ?

                                      and
                                      set(PROJECT_SOURCES ....)contains your new class ?
                                      as well as
                                      qt5_wrap_cpp qt4_wrap_cpp() (I think that was needed for older version ?)

                                      S Offline
                                      S Offline
                                      SPlatten
                                      wrote on 31 May 2022, 12:37 last edited by
                                      #17

                                      @J-Hilk , Unfortunately, still the same result.

                                      Kind Regards,
                                      Sy

                                      J 1 Reply Last reply 31 May 2022, 12:39
                                      0
                                      • S SPlatten
                                        31 May 2022, 12:37

                                        @J-Hilk , Unfortunately, still the same result.

                                        J Offline
                                        J Offline
                                        J.Hilk
                                        Moderators
                                        wrote on 31 May 2022, 12:39 last edited by
                                        #18

                                        @SPlatten Well,

                                        I'm sorry to say it, but I'm out of ideas. My experience with cmake is very limited and does not reach further :(


                                        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                                        Q: What's that?
                                        A: It's blue light.
                                        Q: What does it do?
                                        A: It turns blue.

                                        S 1 Reply Last reply 31 May 2022, 12:41
                                        0
                                        • J J.Hilk
                                          31 May 2022, 12:39

                                          @SPlatten Well,

                                          I'm sorry to say it, but I'm out of ideas. My experience with cmake is very limited and does not reach further :(

                                          S Offline
                                          S Offline
                                          SPlatten
                                          wrote on 31 May 2022, 12:41 last edited by
                                          #19

                                          @J-Hilk , thanks for your time and efforts.

                                          Kind Regards,
                                          Sy

                                          JoeCFDJ 1 Reply Last reply 31 May 2022, 13:05
                                          0
                                          • S SPlatten
                                            31 May 2022, 12:41

                                            @J-Hilk , thanks for your time and efforts.

                                            JoeCFDJ Offline
                                            JoeCFDJ Offline
                                            JoeCFD
                                            wrote on 31 May 2022, 13:05 last edited by JoeCFD
                                            #20

                                            @SPlatten in your source dir where cmake file is located do the following:
                                            mkdir build
                                            cd build
                                            cmake .. -Dyour settings
                                            make -j4

                                            Try to build your code in the build folder all the time. In case you have your vtable issues, simply rm -rf * to delete everything in build dir and redo cmake. Do this only in build dir. Be very careful with rm -rf *. You have to have svn or git for your sources.

                                            S 2 Replies Last reply 31 May 2022, 13:25
                                            0

                                            2/60

                                            31 May 2022, 11:58

                                            topic:navigator.unread, 58
                                            • Login

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