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. can't find linker symbol for virtual table for `Controller' value
Forum Updated to NodeBB v4.3 + New Features

can't find linker symbol for virtual table for `Controller' value

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 838 Views 1 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.
  • M Offline
    M Offline
    maxp
    wrote on last edited by
    #1

    Re: Can't find linker symbol for virtual table

    Hi, the linker symbol problem as mentioned in the topic above still seems to be present?

    I made a small code example with which I keep on having the notification "can't find linker symbol for virtual table for 'Controller' value" in QtCreator while running the application in debug mode and having a breakpoint on "Controller controller;". Even after doing a fresh clean, qmake and build.

    • Platform: Windows 10
    • IDE: QtCreator version 4.11.1 (Built on Feb 5 2020).
    • Kit: Desktop Qt 5.12.6 MinGW 32-bit
    #include "Controller.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        Controller controller;                   // Put breakpoint here
        return a.exec();
    }
    
    // Controller.h
    #ifndef CONTROLLER_H
    #define CONTROLLER_H
    
    #include "MainWindow.h"
    #include <QObject>
    
    class Controller : public QObject
    {
        Q_OBJECT
    
    public:
        Controller(QObject *parent = nullptr);
        ~Controller();
    
    private:
        MainWindow *m_mainWindow;
    };
    #endif // CONTROLLER_H
    
    // Controller.cpp
    #include "Controller.h"
    
    Controller::Controller(QObject* parent)
        : QObject(parent)
        //, m_mainWindow(new MainWindow())  // Virtual table notification occurs no matter if this line is commented or not
    {
    }
    
    Controller::~Controller()
    {
    }
    
    // MainWindow.h
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        MainWindow(QWidget *parent = nullptr);
        ~MainWindow();
    };
    #endif // MAINWINDOW_H
    
    // MainWindow.cpp
    #include "MainWindow.h"
    
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
    {
    }
    
    MainWindow::~MainWindow()
    {
    }
    

    So, I got these virtual table notifications in debug mode in a larger program. I then created a completely new Qt Widgets Application and just added the Controller class in between. Initializing the m_mainWindow pointer or not and cleaning it up in the example does not change anything for the notification. Am I missing anything here or is there some problem with QtCreator or so?

    With kind regards

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maxp
      wrote on last edited by
      #2

      Pro file

      QT       += core gui
      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
      CONFIG += c++11
      DEFINES += QT_DEPRECATED_WARNINGS
      
      SOURCES += \
          main.cpp \
          Controller.cpp \
          MainWindow.cpp
      
      HEADERS += \
          Controller.h \
          MainWindow.h
      
      1 Reply Last reply
      0
      • M Offline
        M Offline
        maxp
        wrote on last edited by
        #3

        The notification is not shown in the following cases:

        • when building the same code with MinGW 64-bit (instead of the 32-bit)
        • when adding controller.setObjectName("Controller");
        • using Controller *controller = new Controller(); and deleting it at the end
        kshegunovK 1 Reply Last reply
        0
        • M maxp

          The notification is not shown in the following cases:

          • when building the same code with MinGW 64-bit (instead of the 32-bit)
          • when adding controller.setObjectName("Controller");
          • using Controller *controller = new Controller(); and deleting it at the end
          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @maxp said in can't find linker symbol for virtual table for &#x60;Controller' value:

          when building the same code with MinGW 64-bit (instead of the 32-bit)

          Then probably doesn't mean anything. Does your code run correctly otherwise?

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            maxp
            wrote on last edited by
            #5

            Thanks for answering. Yes, I haven't spot any problems yet with running apart from that notification.
            But since I get it here on several Windows computers, I wanted to be sure.

            kshegunovK 1 Reply Last reply
            0
            • M maxp

              Thanks for answering. Yes, I haven't spot any problems yet with running apart from that notification.
              But since I get it here on several Windows computers, I wanted to be sure.

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #6

              Well, my best advice is keep an eye on it, if it causes trouble in the future then revisit the issue. I couldn't spot anything obvious in the code itself, and it disappearing with a different version of the same compiler probably means it's some peculiarity of the linkage that's probably irrelevant.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              2

              • Login

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