Results 1 to 7 of 7

Thread: can't find linker symbol for virtual table for `QString::Data' value

  1. #1
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default can't find linker symbol for virtual table for `QString::Data' value

    Hi,
    my project is quite big (174 files as of now) so I can't really put up the code here, I'll try to provide the essential parts (see below).
    Nonetheless I would ask you to help me to understand a runtime error message:

    can't find linker symbol for virtual table for `QString::Data' value
    found `QString::shared_null' instead
    This appears when I instantiate a QObject derived class. There are several QStrings being passed to the object with the construction.

    The above error message appears when both of the following facts are given:
    1. One of the QStrings is empty (doesn't matter if I pass an empty String variable, "" or QString("))
    2. I have a breakpoint inside the object

    A signal that should be emitted from that QObject is *not* being emitted in case of 1..

    I have tried to narrow down the problem, but as of now it seems to be in the very moment of construction.

    I thought it was perfectly normal to pass empty Strings - isn't it?

    I have cleaned, run qmake, built everything new, restarted QtCreator, erased the -pro-user file - all to no avail.

    Any ideas how to hunt down this problem?
    I have a tendency of not knowing basic things because I've only started c++/Qt about a year ago.

    Header of the abstract class:
    Qt Code:
    1. class AbstractApp: public QObject
    2. {
    3. Q_OBJECT
    4. public:
    5. AbstractApp(QString passedAppName,
    6. QString kursName,
    7. QString passedRoomId,
    8. MyModel* myModel,
    9. MyRoomModel* passedRoomModel,
    10. MySchedModel* passedSchedModel,
    11. ClassroomGraphicsScene *scene,
    12. QObject *parent);
    13. //and much more
    To copy to clipboard, switch view to plain text mode 
    Implementation of the abstract class:
    Qt Code:
    1. AbstractApp::AbstractApp(QString passedAppName,
    2. QString kursName,
    3. QString passedRoomId,
    4. MyModel* parentModel,
    5. MyRoomModel* passedRoomModel,
    6. MySchedModel* passedSchedModel,
    7. ClassroomGraphicsScene *scene,
    8. QObject *parent)
    9. :QObject(parent)
    10. {
    11. //much
    12. }
    To copy to clipboard, switch view to plain text mode 

    Header of a derived class:
    Qt Code:
    1. class App_Raumbau : public AbstractApp
    2. {
    3. Q_OBJECT
    4. public:
    5. App_Raumbau(QString passedAppName,
    6. QString kursName,
    7. QString passedRoomId,
    8. QVector<TischKlasse*> passedTischVektor,
    9. MyModel* parentModel,
    10. MyRoomModel* passedRoomModel,
    11. MySchedModel* passedSchedModel,
    12. ClassroomGraphicsScene *scene,
    13. QObject *parent);
    14. //and much more
    To copy to clipboard, switch view to plain text mode 
    Implementation of a derived class:
    Qt Code:
    1. App_Raumbau::App_Raumbau(QString passedAppName,
    2. QString kursName,
    3. QString passedRoomId,
    4. QVector<TischKlasse*> passedTischVektor,
    5. MyModel *parentModel,
    6. MyRoomModel *passedRoomModel,
    7. MySchedModel* passedSchedModel,
    8. ClassroomGraphicsScene *scene,
    9. QObject *parent)
    10. :AbstractApp(passedAppName,
    11. kursName,
    12. passedRoomId,
    13. parentModel,
    14. passedRoomModel,
    15. passedSchedModel,
    16. scene,
    17. parent)
    18.  
    19. { //much
    To copy to clipboard, switch view to plain text mode 
    I can assure the pointers are not the problem - the error message depends on empty strings:

    Constructing in mainWindow.cpp (gives error message):
    Qt Code:
    1. app=new App_Raumbau("Raumbau", "Test", "", this->tischVektor, this->model,this->roomModel, this->schedModel, this->scene, 0);
    To copy to clipboard, switch view to plain text mode 

    Constructing in mainWindow.cpp (gives NO error message):
    Qt Code:
    1. app=new App_Raumbau("Raumbau", "Test", "Test", this->tischVektor, this->model,this->roomModel, this->schedModel, this->scene, 0);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: can't find linker symbol for virtual table for `QString::Data' value

    If you have pointer members, make sure they are all initialized, sounds like you have a connect that has a garbage sender pointer.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: can't find linker symbol for virtual table for `QString::Data' value

    Thank you, high_flyer! I've looked into this and I am sure none of the passed pointers are uninitialized and none of the pointers that are members are uninitialized.

    [I have to admit that the signal problem was not connected to the above error message - it's probably generally not a good idea to emit a signal from the constructor of a class... sorry for that misleading part - the connection just had not been set up properly.]

    Still the problem is - quite odd - :
    - Whenever I pass "" as an argument to the constructor I recieve the vtable error message when entering the class
    - Without a breakpoint in the class I don't have (or: don't see?) the error message.

    I try to understand what the message wants to tell me.

    can't find linker symbol for virtual table
    So Qt has an internal table to link variables. Is that made for signals & slots? Or is if for debugging purposes only?

    for `QString::Data' value
    That means: there is a String data to be looked up - but it can't be found

    found `QString::shared_null' instead
    What the heck? Instead of data it found null - ok. But shared_null?

    And another thing[tm]:
    When I pass two empty strings I recieve the same error message twice

    Yet another addition:
    It doesn't change anything when I change the constructor of the derived class to this:
    Qt Code:
    1. App_Raumbau::App_Raumbau(QString passedAppName,
    2. QString kursName,
    3. QString passedRoomId,
    4. QVector<TischKlasse*> passedTischVektor,
    5. MyModel *parentModel,
    6. MyRoomModel *passedRoomModel,
    7. MySchedModel* passedSchedModel,
    8. ClassroomGraphicsScene *scene,
    9. QObject *parent)
    10. :AbstractApp("dummy",//passedAppName,
    11. "dummy",//kursName,
    12. "dummy",//passedRoomId,
    13. parentModel,
    14. passedRoomModel,
    15. passedSchedModel,
    16. scene,
    17. parent)
    18.  
    19. { //much
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: can't find linker symbol for virtual table for `QString::Data' value

    I have - by now - pretty much ruled out that it is something inside the constructor that causes the problem. It seems to occur in the very calling.

    I could comment out the derived constructor's content entirely - same error message.
    I 've cut down the constructor of my abstract class to the bare minimum (see below) - same error message

    It is simply invoking the beast with an empty string that causes the problem. As soon as Qt debugger then steps into the App_Raumbau file I am up shit creek.

    Here is the minimum constructor of the abstract class (though I think the problem shouldn't be here, see the "dummys" in my last post):
    Qt Code:
    1. AbstractApp::AbstractApp(QString passedAppName,
    2. QString kursName,
    3. QString passedRoomId,
    4. MyModel* parentModel,
    5. MyRoomModel* passedRoomModel,
    6. MySchedModel* passedSchedModel,
    7. ClassroomGraphicsScene *scene,
    8. QObject *parent)
    9. :QObject(parent)
    10. {
    11. this->parentObject=parent;
    12. this->parentScene=scene;
    13. this->model=parentModel;
    14. this->roomModel=passedRoomModel;
    15. this->schedModel=passedSchedModel;
    16. this->nameString=passedAppName;
    17. this->currentKursName=kursName;
    18. this->currentRoomId=passedRoomId;
    19.  
    20.  
    21. helpButton=new HelperButton(model->getMetaDBDirectData("PultIconGröße").toInt()*model->getMetaDBDirectData("ZoomFaktor").toFloat(),this->model,0,parentScene);
    22. this->linksButton = new ButtonItem(model->getMetaDBDirectData("ButtonGröße").toInt()*this->model->getZoomFactor(), model, 0, this->parentScene);
    23. this->rechtsButton = new ButtonItem(model->getMetaDBDirectData("ButtonGröße").toInt()*this->model->getZoomFactor(), model, 0, this->parentScene);
    24. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: can't find linker symbol for virtual table for `QString::Data' value

    I have - by now - pretty much ruled out that it is something inside the constructor that causes the problem. It seems to occur in the very calling.
    How did you check that?

    Try the following:
    make your QString parameters pointers, and initialize them before you call the constructor, and pass the initialized pointers.

    I try to understand what the message wants to tell me.
    It says it trying to to resolve a dynamic type by looking at the virtual call table and it can't find what it is looking for.
    http://en.wikipedia.org/wiki/Virtual_method_table
    This usually may indicate bad initialization of a used polymorphic object.

    can you show the implementation of your AbstractApp constructor, specifically the member initialization?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #6
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: can't find linker symbol for virtual table for `QString::Data' value

    what compiler and system are you using?
    How did you build Qt? What compiler and version did you use to build Qt?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  7. #7
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: can't find linker symbol for virtual table for `QString::Data' value

    Hm. It's been quite some time since then. I think I've just downloaded the installer.

    I work on a Win7 64bit system

    Creator's about states:
    Qt Creator 2.0.1
    Based on Qt 4.7.0 (32 bit)
    Built Aug 24 2010
    Revision 97d831e3de

    The compiler is mingw32

Similar Threads

  1. Replies: 1
    Last Post: 8th June 2011, 14:13
  2. Replies: 3
    Last Post: 22nd February 2011, 08:53
  3. QSharedDataPointer and Data with virtual functions
    By niko in forum Qt Programming
    Replies: 0
    Last Post: 2nd February 2010, 08:23
  4. Find item in table
    By JohnToddSr in forum Qt Programming
    Replies: 1
    Last Post: 3rd July 2009, 16:24
  5. Linker chokes on virtual methods
    By kahahn in forum General Programming
    Replies: 2
    Last Post: 23rd June 2009, 20:58

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.