Results 1 to 4 of 4

Thread: undefined symbol while loading plugin

  1. #1
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Unhappy undefined symbol while loading plugin

    Hi,

    I have a plugin library (like the QT plug-and-paint example) that contains a series of QWidgets to enter data.

    The interface of the plugin has a pure virtual fuction called QWidget* impMainModules::loadScreen(QString pluginName) that returns a widget bases on a plugin name.

    All worked fine until I wanted to create a QtableModel to use in some of the widgets:
    Qt Code:
    1. class fieldInRowModel : public QAbstractTableModel
    2. {
    3. Q_OBJECT
    4. public:
    5. fieldInRowModel(QObject *parent=0);
    6. ~fieldInRowModel();
    7.  
    8. int rowCount(const QModelIndex & parent = QModelIndex()) const;
    9. int columnCount(const QModelIndex &parent = QModelIndex()) const;
    10. QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    11. void setDatabase (QSqlDatabase db);
    12. private:
    13. QSqlDatabase database;
    14.  
    15. };
    To copy to clipboard, switch view to plain text mode 

    Implemented as:
    Qt Code:
    1. fieldInRowModel::fieldInRowModel(QObject *parent)
    2. {
    3.  
    4. }
    5.  
    6. fieldInRowModel::~fieldInRowModel()
    7. {
    8.  
    9. }
    10.  
    11. int fieldInRowModel::rowCount(const QModelIndex &) const
    12. {
    13. return 0; //Test value
    14. }
    15.  
    16. int fieldInRowModel::columnCount(const QModelIndex &) const
    17. {
    18. return 0; //Test value
    19. }
    20. QVariant fieldInRowModel::data(const QModelIndex &/*index*/, int /*role*/) const
    21. {
    22. return QVariant(); //Test value
    23. }
    24. void fieldInRowModel::setDatabase (QSqlDatabase db)
    25. {
    26. database = db;
    27. }
    To copy to clipboard, switch view to plain text mode 

    fieldInRowModel is in a separate file called moduleclasses.h and cpp that are part of the plugin library project .

    Now, with the inclusion of this class in the plugin library, I get the following error when the main application intents to load the plugin.
    Qt Code:
    1. undefined symbol: _ZTV15fieldInRowModel
    To copy to clipboard, switch view to plain text mode 

    fieldInRowModel is internal for the library thus the main application should not know that it exists.

    Any idea how to fix it?

    Thanks a lot!
    Carlos.

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: undefined symbol while loading plugin

    From plugin you are exposing only interfaces or types known to plugin user (application).
    Apparently you are trying to expose from plugin to some application custom type: fieldInRowModel.
    Type fieldInRowModel should be visible for application as QAbstractTableModel type, nothing more.

  3. #3
    Join Date
    Aug 2011
    Location
    Seoul, Korea
    Posts
    46
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: undefined symbol while loading plugin

    Qt Code:
    1. QVariant fieldInRowModel::data(const QModelIndex &/*index*/, int /*role*/) const
    2. {
    3. return QVariant(); //Test value
    4. }
    To copy to clipboard, switch view to plain text mode 

    I guess you might have put your code like that on purpose. Just double check you do aware your code has some problem right? You didn't specify the parameter name in signature of your function definition.
    Dong Back Kim

  4. #4
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: undefined symbol while loading plugin

    Hi,

    The problem was related to the way I included some header files, so they were exposed to the plugin user.

    Thanks.

Similar Threads

  1. Replies: 0
    Last Post: 10th May 2011, 14:58
  2. Strange undefined symbol error
    By mhoover in forum General Programming
    Replies: 3
    Last Post: 1st November 2010, 21:05
  3. Replies: 1
    Last Post: 22nd June 2010, 19:56
  4. QtPlugin and undefined symbol
    By Mikoskay in forum Qt Programming
    Replies: 1
    Last Post: 11th February 2010, 12:04
  5. undefined symbol in library
    By quickNitin in forum General Programming
    Replies: 1
    Last Post: 16th November 2006, 10:50

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.